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 #1091 #1178

Merged
Merged

Conversation

filipproch
Copy link
Contributor

Fixes #1091

@@ -127,7 +127,7 @@ export class ValidateCustomFieldsInterceptor implements NestInterceptor {
const map: { [inputName: string]: string } = {};

for (const selection of operation.selectionSet.selections) {
if (selection.kind === 'Field') {
if (selection.kind === 'Field' && !selection.name.value.startsWith('__')) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we be sure that this will not have unintended consequences? E.g. what if I name my custom field '__mrp'?

Is there an argument against checking for the full string '__typename'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GraphQL is using "__" in various places for internal field.

https://graphql.org/learn/introspection/
or
__resolveType

so I felt to future proof it in case there would be some additions to GraphQL spec in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you prefer just __typename - I will change it

Copy link
Member

Choose a reason for hiding this comment

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

I just had another thought - perhaps a way to avoid the entire issue with the naming convention is to just make the function ignore an undefined inputType on line 133, with const arg of inputType?.args ?? [].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@filipproch
Copy link
Contributor Author

filipproch commented Oct 20, 2021 via email

@michaelbromley michaelbromley merged commit f856491 into vendure-ecommerce:master Oct 20, 2021
@michaelbromley
Copy link
Member

Thank you!

@filipproch filipproch deleted the fix_core_graphql branch October 20, 2021 14:25
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.

Custom mutation throws: "Cannot read property 'args' of undefined"
2 participants