Issue with `allDocument` GraphQL query causing errors for multiple brands using different Sanity accounts.
2 replies
Last updated: Apr 27, 2023
A
Hello everybody,we are experiencing some issues for the last 2 days with an
POSTing this query to
works just fine.
When we pass it to our bff the query gets rewritten by our GraphQL client (as it always has been in the last months) as follows:
This query results in the following error, both if we call our bff or if we call directly Sanity’s GraphQL endpoint:
The strange thing is that we didn’t change anything our side, and we haven’t experienced any issue since the last Tuesday (when suddenly this errors started). We have multiple brands with shared code but different Sanity accounts, and everyone of them has the same exact problem on all datasets. We tried with a different GraphQL client (Apollo client instead of
allDocumentGraphQL query.This is the original, very basic query:
query getRelated { allDocument { _id _type } }
https://[project].<http://api.sanity.io/v1/graphql/[dataset]/default|api.sanity.io/v1/graphql/[dataset]/default>
When we pass it to our bff the query gets rewritten by our GraphQL client (as it always has been in the last months) as follows:
query getRelated { allDocument { ... on Document { _id _type } } }
{ "errors": [ { "message": "Cannot read properties of undefined (reading 'length')", "locations": [ { "line": 2, "column": 3 } ], "path": [ "allDocument" ] } ], "data": null }
graphql-js+
cross-fetch) but with no luck (same error).Anybody experiencing the same issue?
Apr 14, 2023, 8:53 AM
J
Nice. I didn’t know you could use
I use
The error says the list is empty. You didn’t change the filter conditions?
... on Document {…I’ll have to try that for handling related content to our various page types.
I use
createSchemaCustomizationand
actions.createTypesand
schema.buildObjectTypeto attach related content of each type, and then access them in the template query like…
relatedPosts { ...cardNode } relatedAssets { ...cardNodeAsset } relatedPlaybooks { ...cardNodePlaybook }
Apr 26, 2023, 6:05 PM
A
Hey Josh, thanks for your reply. In fact I didn’t write that query, it was the GraphQL client rewriting our plain query (without
We locked the package version to v3 and now everything is back to normal, I honestly found it a bit scary (that library is widely used) but no one else seemed to have any problem so maybe we are overreacting
🙂.
… on Document) to that one. We investigated further and we found out that it was a single package (
@graphql-codegen/fragment-matcher) that got updated to v4 and changed the Document Typescript type automatically generated by the codegen - and that broke the
allDocumentquery.
We locked the package version to v3 and now everything is back to normal, I honestly found it a bit scary (that library is widely used) but no one else seemed to have any problem so maybe we are overreacting
🙂.
Apr 27, 2023, 1:02 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.