You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with GraphiQL, usually a number of queries are written down in the same document for convenience:
querytodos {
todos {
idtext
}
}
mutationadd {
createTodo(data: { text: "dqwdwq" }) {
id
}
}
However, when trying to execute any of the queries, the GraphiQL sends the whole document to the server containing every operation out there, the one to run is sent via operationName parameter:
graphql_server2 doesn't handle such scenarios and prints the This document does not define any operations error due to this code:
OperationDefinitionContextgetOperation(
DocumentContext document, String? operationName) {
var ops = document.definitions.whereType<OperationDefinitionContext>();
if (operationName ==null) {
return ops.length ==1? ops.first
:throwGraphQLException.fromMessage(
'This document does not define any operations.');
} else {
return ops.firstWhere((d) => d.name == operationName,
orElse: (() =>throwGraphQLException.fromMessage(
'Missing required operation "$operationName".')));
}
}
The appropriate solution would be to respect the operationName and find the operation with the specified name in the ops list, not throw an error if there's more than 1 (or less than 1) operation - error should be thrown if there's 0 operations in the document of the specified operationName doesn't correspond to any provided.
The text was updated successfully, but these errors were encountered:
When working with GraphiQL, usually a number of queries are written down in the same document for convenience:
However, when trying to execute any of the queries, the GraphiQL sends the whole document to the server containing every operation out there, the one to run is sent via
operationName
parameter:graphql_server2
doesn't handle such scenarios and prints theThis document does not define any operations
error due to this code:The appropriate solution would be to respect the
operationName
and find the operation with the specified name in theops
list, not throw an error if there's more than 1 (or less than 1) operation - error should be thrown if there's 0 operations in the document of the specifiedoperationName
doesn't correspond to any provided.The text was updated successfully, but these errors were encountered: