question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Describe the bug Custom mutation throws the following error.

TypeError: Cannot read property 'args' of undefined
[run:server]     at ValidateCustomFieldsInterceptor.getArgumentMap (/app/node_modules/@vendure/core/src/api/middleware/validate-custom-fields-interceptor.ts:133:45)
[run:server]     at ValidateCustomFieldsInterceptor.intercept (/app/node_modules/@vendure/core/src/api/middleware/validate-custom-fields-interceptor.ts:50:45)
[run:server]     at /app/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:23:36
[run:server]     at Object.handle (/app/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:21:56)
[run:server]     at IdInterceptor.intercept (/app/node_modules/@vendure/core/src/api/middleware/id-interceptor.ts:38:21)
[run:server]     at /app/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:23:36
[run:server]     at InterceptorsConsumer.intercept (/app/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:25:24)
[run:server]     at target (/app/node_modules/@nestjs/core/helpers/external-context-creator.js:76:60)
[run:server]     at processTicksAndRejections (internal/process/task_queues.js:95:5)
[run:server]     at /app/node_modules/@nestjs/core/helpers/external-proxy.js:9:24

To Reproduce Steps to reproduce the behavior:

Define custom API extension (shop api)

extend type Mutation {
  doSomething: ActiveOrderResult!
}
  1. Invoke this mutation in production (shopApiDebug: false in vendure config - doesnt seem to be happening locally when developing)
  2. See error

Expected behavior No error. Seems this started with migration to Vendure 1.2.0 (worked before)

Environment (please complete the following information):

  • @vendure/core version: 1.2.1
  • Nodejs version: 14.17
  • Database (mysql/postgres etc): postgres

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
filipprochcommented, Sep 15, 2021

@michaelbromley I think I finally understood what is causing this. Its the proxy GraphQL which I am using (which is stitching two schemas together to create a single API- using @graphql-tools/stitch) a __typename everywhere.

Why it appeared now? I updated to the latest @graphql-tools version. Why I thought it appears randomly? I was testing it sometimes on the website, sometimes directly against the endpoint.

The solution could be to add check in the for loop, together with selection.kind === 'Field' to filter __typename out.

Should I submit a PR for this?

PS: sorry for spamming this thread - wanted to share the progress

1reaction
filipprochcommented, Sep 15, 2021

I did some changes to my GraphQL schema - so its probably connected to that rather than the version bump. I will try to debug it further and let you know here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Cannot read property 'args' of undefined when trying ...
I've got a schemaRetriever service that retrieves the schemas from 3 GraphQL Api's. For now I'm trying to get 1 stitch working so...
Read more >
Cannot read property 'errors' of undefined in mutations - Help
Hey, community! I updated packages(apollo/client, react-scripts, typescript, etc) to the latest versions in my project and got errors in ...
Read more >
Prisma throws an error "TypeError: cannot read property ...
I wanted to make a chat app to practice working with graphql and node, for database I used prisma. I was doing everything...
Read more >
Null and undefined (Reference) - Prisma
Use case: null and undefined in a GraphQL resolver. In the following example mutation that updates a user, both authorEmail and name accept...
Read more >
3. Adding mutations to your API - GraphQL Nexus
Writing GraphQL mutations; Exposing GraphQL objects for mutation operations ... + throw new Error('Could not find draft with id ' + args.draftId).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found