Class ExecutableNormalizedOperationToAstCompiler
java.lang.Object
graphql.normalized.ExecutableNormalizedOperationToAstCompiler
This class can take a list of
ExecutableNormalizedFields and compiling out a
normalised operation Document that would represent how those fields
maybe executed.
This is essentially the reverse of ExecutableNormalizedOperationFactory which takes
operation text and makes ExecutableNormalizedFields from it, this takes ExecutableNormalizedFields
and makes operation text from it.
You could for example send that operation text onto to some other graphql server if it has the same schema as the one provided.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe result is aDocumentand a map of variables that would go with that document. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static @NotNull Value<?> argValue(ExecutableNormalizedField executableNormalizedField, String argName, NormalizedInputValue normalizedInputValue, VariableAccumulator variableAccumulator) private static Value<?> argValue(ExecutableNormalizedField executableNormalizedField, String argName, @Nullable Object value, VariableAccumulator variableAccumulator) compileToDocument(@NotNull GraphQLSchema schema, OperationDefinition.Operation operationKind, @Nullable String operationName, @NotNull List<ExecutableNormalizedField> topLevelFields, @Nullable VariablePredicate variablePredicate) This will compile an operation textDocumentwith possibly variables from the givenExecutableNormalizedFields TheVariablePredicateis used called to decide if the given argument values should be made into a variable OR inlined into the operation text as a graphql literal.compileToDocument(@NotNull GraphQLSchema schema, OperationDefinition.Operation operationKind, @Nullable String operationName, @NotNull List<ExecutableNormalizedField> topLevelFields, @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, @Nullable VariablePredicate variablePredicate) This will compile an operation textDocumentwith possibly variables from the givenExecutableNormalizedFields TheVariablePredicateis used called to decide if the given argument values should be made into a variable OR inlined into the operation text as a graphql literal.createArguments(ExecutableNormalizedField executableNormalizedField, VariableAccumulator variableAccumulator) private static @NotNull GraphQLFieldDefinitiongetFieldDefinition(GraphQLSchema schema, String parentType, ExecutableNormalizedField nf) private static @Nullable GraphQLObjectTypegetOperationType(@NotNull GraphQLSchema schema, OperationDefinition.Operation operationKind) selectionForNormalizedField(GraphQLSchema schema, ExecutableNormalizedField executableNormalizedField, @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, VariableAccumulator variableAccumulator) private static FieldselectionForNormalizedField(GraphQLSchema schema, String objectTypeName, ExecutableNormalizedField executableNormalizedField, @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, VariableAccumulator variableAccumulator) private static SelectionSetselectionSet(List<Field> fields) private static @Nullable SelectionSetselectionSetOrNullIfEmpty(List<Selection<?>> selections) subselectionsForNormalizedField(GraphQLSchema schema, @NotNull String parentOutputType, List<ExecutableNormalizedField> executableNormalizedFields, @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, VariableAccumulator variableAccumulator)
-
Constructor Details
-
ExecutableNormalizedOperationToAstCompiler
public ExecutableNormalizedOperationToAstCompiler()
-
-
Method Details
-
compileToDocument
public static ExecutableNormalizedOperationToAstCompiler.CompilerResult compileToDocument(@NotNull @NotNull GraphQLSchema schema, @NotNull OperationDefinition.Operation operationKind, @Nullable @Nullable String operationName, @NotNull @NotNull List<ExecutableNormalizedField> topLevelFields, @Nullable @Nullable VariablePredicate variablePredicate) This will compile an operation textDocumentwith possibly variables from the givenExecutableNormalizedFields TheVariablePredicateis used called to decide if the given argument values should be made into a variable OR inlined into the operation text as a graphql literal.- Parameters:
schema- the graphql schema to useoperationKind- the kind of operationoperationName- the name of the operation to usetopLevelFields- the top levelExecutableNormalizedFields to start fromvariablePredicate- the variable predicate that decides if arguments turn into variables or not during compilation- Returns:
- a
ExecutableNormalizedOperationToAstCompiler.CompilerResultobject
-
compileToDocument
public static ExecutableNormalizedOperationToAstCompiler.CompilerResult compileToDocument(@NotNull @NotNull GraphQLSchema schema, @NotNull OperationDefinition.Operation operationKind, @Nullable @Nullable String operationName, @NotNull @NotNull List<ExecutableNormalizedField> topLevelFields, @NotNull @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, @Nullable @Nullable VariablePredicate variablePredicate) This will compile an operation textDocumentwith possibly variables from the givenExecutableNormalizedFields TheVariablePredicateis used called to decide if the given argument values should be made into a variable OR inlined into the operation text as a graphql literal.- Parameters:
schema- the graphql schema to useoperationKind- the kind of operationoperationName- the name of the operation to usetopLevelFields- the top levelExecutableNormalizedFields to start fromnormalizedFieldToQueryDirectives- the map of normalized field to query directivesvariablePredicate- the variable predicate that decides if arguments turn into variables or not during compilation- Returns:
- a
ExecutableNormalizedOperationToAstCompiler.CompilerResultobject
-
subselectionsForNormalizedField
private static List<Selection<?>> subselectionsForNormalizedField(GraphQLSchema schema, @NotNull @NotNull String parentOutputType, List<ExecutableNormalizedField> executableNormalizedFields, @NotNull @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, VariableAccumulator variableAccumulator) -
selectionForNormalizedField
private static Map<String,Field> selectionForNormalizedField(GraphQLSchema schema, ExecutableNormalizedField executableNormalizedField, @NotNull @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, VariableAccumulator variableAccumulator) - Returns:
- Map of object type names to list of fields
-
selectionForNormalizedField
private static Field selectionForNormalizedField(GraphQLSchema schema, String objectTypeName, ExecutableNormalizedField executableNormalizedField, @NotNull @NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives, VariableAccumulator variableAccumulator) - Returns:
- Map of object type names to list of fields
-
selectionSetOrNullIfEmpty
@Nullable private static @Nullable SelectionSet selectionSetOrNullIfEmpty(List<Selection<?>> selections) -
selectionSet
-
createArguments
private static List<Argument> createArguments(ExecutableNormalizedField executableNormalizedField, VariableAccumulator variableAccumulator) -
argValue
private static Value<?> argValue(ExecutableNormalizedField executableNormalizedField, String argName, @Nullable @Nullable Object value, VariableAccumulator variableAccumulator) -
argValue
@NotNull private static @NotNull Value<?> argValue(ExecutableNormalizedField executableNormalizedField, String argName, NormalizedInputValue normalizedInputValue, VariableAccumulator variableAccumulator) -
getFieldDefinition
@NotNull private static @NotNull GraphQLFieldDefinition getFieldDefinition(GraphQLSchema schema, String parentType, ExecutableNormalizedField nf) -
getOperationType
@Nullable private static @Nullable GraphQLObjectType getOperationType(@NotNull @NotNull GraphQLSchema schema, @NotNull OperationDefinition.Operation operationKind)
-