From e584edeb16cf289818cd0ee65278950b4cd9e6e6 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 7 Aug 2023 17:11:02 +0200 Subject: [PATCH 1/2] graphql(attachment): prevent null errors --- app/graphql/extensions/attachment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/graphql/extensions/attachment.rb b/app/graphql/extensions/attachment.rb index c0612d8fbdb..633d7a01133 100644 --- a/app/graphql/extensions/attachment.rb +++ b/app/graphql/extensions/attachment.rb @@ -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 From cd85bad37988876ada7eb5a44bcc70a64cc2a972 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 7 Aug 2023 17:11:32 +0200 Subject: [PATCH 2/2] graphql(query): expose __typename and timestamps one some nodes --- app/graphql/api/v2/stored_query.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/graphql/api/v2/stored_query.rb b/app/graphql/api/v2/stored_query.rb index 9111d77c0c7..5650db3fb2c 100644 --- a/app/graphql/api/v2/stored_query.rb +++ b/app/graphql/api/v2/stored_query.rb @@ -242,6 +242,7 @@ def self.get(query_id) } fragment DossierFragment on Dossier { + __typename id number archived @@ -463,6 +464,7 @@ def self.get(query_id) __typename label stringValue + updatedAt ... on DateChamp { date } @@ -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 { @@ -643,6 +647,7 @@ def self.get(query_id) fragment PageInfoFragment on PageInfo { hasPreviousPage hasNextPage + startCursor endCursor } GRAPHQL