createRequest<_Model extends GraphqlModel> method

  1. @protected
  2. @visibleForTesting
Request? createRequest<_Model extends GraphqlModel>({
  1. Query? query,
  2. required QueryAction action,
  3. 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(),
  );
}