Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): don't fail validation on fragments that are not used #24032

Merged
merged 1 commit into from
May 13, 2020

Conversation

pieh
Copy link
Contributor

@pieh pieh commented May 12, 2020

Description

Just having gatsby-transformer-sharp installed (not even in gatsby-config) and not having any image nodes cause query-compiler to fail validation because we use prevalidate rules that include KnownTypeNamesRule on every extracted graphql document. This PR removes that rule from prevalidation.

We also later run full validation on constructed document that stitches query and used fragments, so this PR doesn't completely removes it - it just makes sure that we run it only on fragments that are actually used (I added 2 tests to verify it - one for not used fragment that is using unknown type - which passes validation and one for used fragment that is using unknown type which errors out as expected)

gatsby-transformer-sharp already define schema for ImageSharp so we should not see errors like that when it's actually added to gatsby-config, so this PR is mostly about frustrating issues when package is installed, but not used

--edit - I just noticed to original issue was about contentful and not transformer-sharp ... and for it would also help to use schema customization for generic types like asset (still reasonable thing to do), but this seems to help in other cases (as described above for example)

Related Issues

Fixes #15397

@pieh pieh added the topic: GraphQL Related to Gatsby's GraphQL layer label May 12, 2020
@pieh pieh requested a review from a team as a code owner May 12, 2020 22:33
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 12, 2020
@pieh pieh added status: needs core review Currently awaiting review from Core team member and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 12, 2020
@wardpeet wardpeet merged commit 61d0ef4 into master May 13, 2020
@wardpeet wardpeet deleted the query-compiler-dont-prevalidate-type branch May 13, 2020 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs core review Currently awaiting review from Core team member topic: GraphQL Related to Gatsby's GraphQL layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR #85901 GRAPHQL | gatsby-source-contentful requires Media uploaded to work
3 participants