Merge pull request #8768 from tchak/fix-graphql-attachement
fix(graphql): return empty array when no attachments
This commit is contained in:
commit
f4f55183de
2 changed files with 26 additions and 1 deletions
|
@ -45,7 +45,7 @@ module Extensions
|
||||||
else
|
else
|
||||||
attachment = after_resolve_attachment(value)
|
attachment = after_resolve_attachment(value)
|
||||||
if options[:as] == :multiple
|
if options[:as] == :multiple
|
||||||
[attachment]
|
[attachment].compact
|
||||||
else
|
else
|
||||||
attachment
|
attachment
|
||||||
end
|
end
|
||||||
|
|
|
@ -210,6 +210,18 @@ RSpec.describe Types::DossierType, type: :graphql do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'dossier with message with no attachments' do
|
||||||
|
let(:dossier) { create(:dossier, :en_construction) }
|
||||||
|
let(:query) { DOSSIER_WITH_MESSAGE_QUERY }
|
||||||
|
let(:variables) { { number: dossier.id } }
|
||||||
|
|
||||||
|
before { create(:commentaire, dossier: dossier) }
|
||||||
|
|
||||||
|
it {
|
||||||
|
expect(data[:dossier][:messages]).not_to be_nil
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
DOSSIER_QUERY = <<-GRAPHQL
|
DOSSIER_QUERY = <<-GRAPHQL
|
||||||
query($number: Int!) {
|
query($number: Int!) {
|
||||||
dossier(number: $number) {
|
dossier(number: $number) {
|
||||||
|
@ -351,4 +363,17 @@ RSpec.describe Types::DossierType, type: :graphql do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GRAPHQL
|
GRAPHQL
|
||||||
|
|
||||||
|
DOSSIER_WITH_MESSAGE_QUERY = <<-GRAPHQL
|
||||||
|
query($number: Int!) {
|
||||||
|
dossier(number: $number) {
|
||||||
|
messages {
|
||||||
|
body
|
||||||
|
attachments {
|
||||||
|
filename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GRAPHQL
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue