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
I think its bad that we have to specify the QueryOptions.operationName even when the operation name is part of the query string:
final document =gql(r'''query Example() { id}''');
final options =QueryOptions(document: document);
print(options.operationName) // prints null
Also if the names in QueryOptions.operationName and in the query string don't exactly match the request simply doesn't work and I don't get any exception.
Solution
I've solved this problem on my side by implementing an extension of DocumentNode from gql and using it in QueryOptions
import'package:gql/ast.dart'as ast;
extensionDocumentNodeExtensionon ast.DocumentNode {
String?get operationName {
final node = definitions.first as ast.OperationDefinitionNode;
return node.name?.value;
}
}
final document =gql(r'''query Example() { id}''');
final options =QueryOptions(operationName: document.operationName, document: document);
print(options.operationName) // prints 'Example'
I thought maybe the operation name could be extracted like this by default when QueryOptions.operationName is not specified.
Is this reasonable or am I missing something here?
The text was updated successfully, but these errors were encountered:
I think its bad that we have to specify the
QueryOptions.operationName
even when the operation name is part of the query string:Also if the names in
QueryOptions.operationName
and in the query string don't exactly match the request simply doesn't work and I don't get any exception.Solution
I've solved this problem on my side by implementing an extension of
DocumentNode
from gql and using it inQueryOptions
I thought maybe the operation name could be extracted like this by default when
QueryOptions.operationName
is not specified.Is this reasonable or am I missing something here?
The text was updated successfully, but these errors were encountered: