graphql-query-complexity
graphql-query-complexity copied to clipboard
GQL causes TypeError: "Cannot read properties of undefined (reading 'name')"
This query was in some logs:
mutation {
__typename
}
which caused:
TypeError: Cannot read properties of undefined (reading 'name')\n at QueryComplexity.nodeComplexity (/app/node_modules/graphql-query-complexity/dist/cjs/QueryComplexity.js:105:46
Are mutations configured in the schema of the GraphQL server? Might be the same issue as this one: https://github.com/slicknode/graphql-query-complexity/pull/84
We are having the same (similar) issue. Even if the operation is defined in GraphQL schema but you don't give your actual query a name then it will issue the type error.
For example:
mutation {
doSomething(input: { amount: 1 }) {
result
}
}
will error but
mutation myOperation {
doSomething(input: { amount: 1 }) {
result
}
}
will not.
We are on Apollo 3 and GraphQL (graphql
package) 15