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 for #64: return before error on missing fields #73

Merged

Conversation

rachsmithcodes
Copy link
Contributor

@rachsmithcodes rachsmithcodes commented May 24, 2022

I am getting the error described in #64.

As far as I can tell, it is happening in when a GraphQL document includes a field that doesn't exist on the server schema. In this scenario the validation should add an error like this:

CleanShot 2022-05-24 at 13 07 29

But when it gets run though the NoMissingClientDirectives rule, context.getFieldDef() returns undefined, causing the extension to error on line 103 of validation.js.

Adding an early return if the fieldDef doesn't exist prevents the error.

┆Issue is synchronized with this Jira Task by Unito

@apollo-cla
Copy link

@rachsmithcodes: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@rachsmithcodes rachsmithcodes changed the title Fix for #64 return before error on missing fields Fix for #64: return before error on missing fields May 24, 2022
@@ -175,7 +175,7 @@ export function NoMissingClientDirectives(context: ValidationContext) {
const fieldDef = context.getFieldDef();

// if we don't have a type to check then we can early return
if (!parentType) return;
if (!parentType || fieldDef) return;
Copy link

@pauljohnberry pauljohnberry Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps reverse the check on fieldDef here? !fieldDef

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree it looks like we need to flip this condition, went ahead and made that change in 9d95cac

@alessbell alessbell force-pushed the fix-validation-missing-fields branch from 78e9cc4 to 552dba3 Compare October 16, 2023 15:59
Copy link
Member

@alessbell alessbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rachsmithcodes!

@alessbell alessbell merged commit d07b303 into apollographql:main Oct 16, 2023
1 check passed
@github-actions github-actions bot mentioned this pull request Oct 16, 2023
alessbell added a commit that referenced this pull request Oct 16, 2023
@alessbell
Copy link
Member

Fixed broken test in a follow-on commit: bf80011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants