slicknode/graphql-query-complexity

GQL causes TypeError: "Cannot read properties of undefined (reading 'name')"

sam-super opened this issue · 2 comments

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
ivome commented

Are mutations configured in the schema of the GraphQL server? Might be the same issue as this one: #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