operationFieldNames<TData, TVars> function

List<String> operationFieldNames<TData, TVars>(
  1. DocumentNode document,
  2. String operationName,
  3. Map<String, dynamic> vars,
  4. Map<String, TypePolicy> typePolicies,
  5. Map<String, Set<String>> possibleTypes,
)

Returns the root field names for a given operation.

Implementation

List<String> operationFieldNames<TData, TVars>(
  DocumentNode document,
  String operationName,
  Map<String, dynamic> vars,
  Map<String, TypePolicy> typePolicies,
  Map<String, Set<String>> possibleTypes,
) {
  final operationDefinition = getOperationDefinition(
    document,
    operationName,
  );
  final rootTypename = resolveRootTypename(
    operationDefinition,
    typePolicies,
  );
  final fragmentMap = getFragmentMap(document);
  final fields = expandFragments(
    typename: rootTypename,
    selectionSet: operationDefinition.selectionSet,
    fragmentMap: fragmentMap,
    possibleTypes: possibleTypes,
    variables: vars,
  );
  final typePolicy = typePolicies[rootTypename];
  return fields.map((fieldNode) {
    final fieldPolicy = (typePolicy?.fields ?? const {})[fieldNode.name.value];
    return FieldKey(
      fieldNode,
      vars,
      fieldPolicy,
    ).toString();
  }).toList();
}