Merge pull request #9395 from tchak/graphql-improuve-stored-query

graphql(attachment): prevent null errors
This commit is contained in:
Paul Chavard 2023-08-08 14:22:44 +00:00 committed by GitHub
commit 202e310d03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -242,6 +242,7 @@ class API::V2::StoredQuery
} }
fragment DossierFragment on Dossier { fragment DossierFragment on Dossier {
__typename
id id
number number
archived archived
@ -463,6 +464,7 @@ class API::V2::StoredQuery
__typename __typename
label label
stringValue stringValue
updatedAt
... on DateChamp { ... on DateChamp {
date date
} }
@ -592,11 +594,13 @@ class API::V2::StoredQuery
fragment FileFragment on File { fragment FileFragment on File {
__typename
filename filename
contentType contentType
checksum checksum
byteSize: byteSizeBigInt byteSize: byteSizeBigInt
url url
createdAt
} }
fragment AddressFragment on Address { fragment AddressFragment on Address {
@ -643,6 +647,7 @@ class API::V2::StoredQuery
fragment PageInfoFragment on PageInfo { fragment PageInfoFragment on PageInfo {
hasPreviousPage hasPreviousPage
hasNextPage hasNextPage
startCursor
endCursor endCursor
} }
GRAPHQL GRAPHQL

View file

@ -35,7 +35,7 @@ module Extensions
# is a lazy value (e.g., a Promise like in our case) # is a lazy value (e.g., a Promise like in our case)
def after_resolve(value:, **_rest) def after_resolve(value:, **_rest)
if value.respond_to?(:map) if value.respond_to?(:map)
attachments = value.map { after_resolve_attachment(_1) } attachments = value.map { after_resolve_attachment(_1) }.compact
if options[:as] == :single if options[:as] == :single
attachments.first attachments.first