createRequest<_Model extends GraphqlModel> method
- @protected
- @visibleForTesting
Request?
createRequest<
_Model extends GraphqlModel>({ - Query? query,
- required QueryAction action,
- Map<String, dynamic>? variables,
})
Implementation
@protected
@visibleForTesting
Request? createRequest<_Model extends GraphqlModel>({
Query? query,
required QueryAction action,
Map<String, dynamic>? variables,
}) {
final defaultOperation = ModelFieldsDocumentTransformer.defaultOperation<_Model>(
modelDictionary,
action: action,
query: query,
);
if (defaultOperation == null) return null;
var requestVariables = variables ?? queryToVariables<_Model>(query);
if (variableNamespace != null) {
requestVariables = {variableNamespace!: requestVariables};
}
return Request(
operation: Operation(document: defaultOperation.document),
variables: query?.providerArgs['variables'] ?? requestVariables,
context: query?.providerArgs['context'] != null
? Context.fromMap(Map<String, ContextEntry>.from(query?.providerArgs['context'])
.map((key, value) => MapEntry<Type, ContextEntry>(value.runtimeType, value)))
: Context(),
);
}