Skip to content

Commit

Permalink
fix(core): Fix error in validating custom fields with introspection f…
Browse files Browse the repository at this point in the history
…ields in query

Fixes #1091
  • Loading branch information
filipproch authored Oct 20, 2021
1 parent f76f3ea commit f856491
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/core/e2e/custom-fields.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,24 @@ describe('Custom fields', () => {
`);
}, `relation error`),
);

// https://github.com/vendure-ecommerce/vendure/issues/1091
it('handles well graphql internal fields', async () => {
// throws "Cannot read property 'args' of undefined" if broken
await adminClient.query(gql`
mutation {
__typename
updateProduct(input: { id: "T_1", customFields: { nullable: "some value" } }) {
__typename
id
customFields {
__typename
nullable
}
}
}
`);
});
});

describe('public access', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ export class ValidateCustomFieldsInterceptor implements NestInterceptor {
for (const selection of operation.selectionSet.selections) {
if (selection.kind === 'Field') {
const name = selection.name.value;

const inputType = mutationType.getFields()[name];
if (!inputType) continue;

for (const arg of inputType.args) {
map[arg.name] = this.getInputTypeName(arg.type);
}
Expand Down

0 comments on commit f856491

Please sign in to comment.