createSourceEventStream method
Future<Stream>
createSourceEventStream(
- DocumentContext document,
- OperationDefinitionContext subscription,
- GraphQLSchema schema,
- Map<String?, dynamic> variableValues,
- dynamic initialValue,
)
Implementation
Future<Stream> createSourceEventStream(
DocumentContext document,
OperationDefinitionContext subscription,
GraphQLSchema schema,
Map<String?, dynamic> variableValues,
initialValue) {
var selectionSet = subscription.selectionSet;
var subscriptionType = schema.subscriptionType;
if (subscriptionType == null) {
throw GraphQLException.fromSourceSpan(
'The schema does not define a subscription type.',
subscription.span!);
}
var groupedFieldSet =
collectFields(document, subscriptionType, selectionSet, variableValues);
if (groupedFieldSet.length != 1) {
throw GraphQLException.fromSourceSpan(
'The grouped field set from this query must have exactly one entry.',
selectionSet.span!);
}
var fields = groupedFieldSet.entries.first.value;
var fieldName = fields.first.field!.fieldName.alias?.name ??
fields.first.field!.fieldName.name;
var field = fields.first;
var argumentValues =
coerceArgumentValues(subscriptionType, field, variableValues);
return resolveFieldEventStream(
subscriptionType, initialValue, fieldName, argumentValues);
}