Skip to content

Commit

Permalink
Merge pull request demarches-simplifiees#9395 from tchak/graphql-impr…
Browse files Browse the repository at this point in the history
…ouve-stored-query

graphql(attachment): prevent null errors
  • Loading branch information
tchak authored Aug 8, 2023
2 parents 7e8e597 + cd85bad commit 202e310
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/graphql/api/v2/stored_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def self.get(query_id)
}
fragment DossierFragment on Dossier {
__typename
id
number
archived
Expand Down Expand Up @@ -463,6 +464,7 @@ def self.get(query_id)
__typename
label
stringValue
updatedAt
... on DateChamp {
date
}
Expand Down Expand Up @@ -592,11 +594,13 @@ def self.get(query_id)
fragment FileFragment on File {
__typename
filename
contentType
checksum
byteSize: byteSizeBigInt
url
createdAt
}
fragment AddressFragment on Address {
Expand Down Expand Up @@ -643,6 +647,7 @@ def self.get(query_id)
fragment PageInfoFragment on PageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
GRAPHQL
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/extensions/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def resolve(object:, **_rest)
# is a lazy value (e.g., a Promise – like in our case)
def after_resolve(value:, **_rest)
if value.respond_to?(:map)
attachments = value.map { after_resolve_attachment(_1) }
attachments = value.map { after_resolve_attachment(_1) }.compact

if options[:as] == :single
attachments.first
Expand Down

0 comments on commit 202e310

Please sign in to comment.