queryToVariables<_Model extends GraphqlModel> method

Map<String, dynamic> queryToVariables<_Model extends GraphqlModel>(
  1. Query? query
)

Remove associations from variables and transform them from field names to document node names.

Implementation

Map<String, dynamic> queryToVariables<_Model extends GraphqlModel>(Query? query) {
  if (query?.where == null) return {};
  final adapter = modelDictionary.adapterFor[_Model]!;

  return query!.where!.fold<Map<String, dynamic>>(<String, dynamic>{}, (allVariables, where) {
    final definition = adapter.fieldsToGraphqlRuntimeDefinition[where.evaluatedField];
    if (definition != null && !definition.association) {
      allVariables[definition.documentNodeName] = where.value;
    }
    return allVariables;
  });
}