Package no.sikt.graphql.schema
Class ProcessedSchema
java.lang.Object
no.sikt.graphql.schema.ProcessedSchema
This class represents a fully processed GraphQL schema. This is Graphitron's pre-processing of the schema.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResolved structure of an @orderBy input type, containing the enum definition and the actual fields. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfindInputTables(GenerationField field) Simple method that tries to find a table reference in the input records.@NotNull List<ObjectField> getAllErrors(String typeName) getConnectionObject(String name) getEnum(FieldSpecification field) getEnums()@NotNull AbstractObjectDefinition<?, ?> getErrorTypeDefinition(String name) getException(String name) @NotNull List<ExceptionDefinition> getImplementationsForInterface(String interfaceName) getImplementationsForInterface(InterfaceDefinition interfaceDefinition) getInputType(String name) getInputType(GenerationField field) getInterface(String name) getInterface(FieldSpecification field) Finds node type for a node ID field.getNodeConfigurationForTypeOrThrow(String typeName) Returns theNodeConfigurationfor the given type name, or throws if the@nodeconfiguration is missing.Returns theNodeConfigurationfor the given object, or throws if the@nodeconfiguration is missing.getNodeType(String name) Finds node type for a node ID field.getNodeTypesWithTable(JOOQMapping table) getObject(FieldSpecification field) getRecordType(String name) getRecordType(GenerationField field) Map<String, RecordObjectSpecification<? extends GenerationField>> getResolvedOrderInput(InputField orderInputField) Returns the ObjectDefinition for each Type in a union given that the name supplied is a union.getTypesFromInterfaceOrUnion(RecordObjectSpecification<?> definition) Returns the ObjectDefinition for each type implementing an interface or union given its definitiongetUnion(GenerationField field) getUnionSubTypes(String objectName) booleanbooleanhasJavaRecord(String typeName) booleanhasJavaRecord(GenerationField field) booleanhasJOOQRecord(String name) booleanhasJOOQRecord(GenerationField field) booleanbooleanhasRecord(GenerationField field) booleanhasTableObject(String name) booleanhasTableObject(FieldSpecification field) booleanhasTableObjectForObject(RecordObjectSpecification<?> object) booleanimplementsInterface(String name, String interfaceName) booleanimplementsInterface(FieldSpecification field, String interfaceName) booleanimplementsNode(String name) booleanimplementsNode(FieldSpecification field) inferDataTargetForMutation(ObjectField initialTarget) Finds the target field which the returned data from mutation should be outputted.booleaninvokesSubquery(GenerationField field, JOOQMapping currentTable) Determines whether the field requires a correlated subquery in the generated database query.booleanisConnectionObject(String name) booleanbooleanbooleanisEdgeObject(String name) booleanbooleanbooleanisEnum(GenerationField field) booleanisException(String name) booleanbooleanbooleanisExceptionUnion(String name) booleanbooleanisFederationService(GenerationField target) booleanisInputType(String name) booleanisInputType(FieldSpecification field) booleanbooleanisInterface(String name) booleanisInterface(GenerationField field) booleanbooleanisMultiTableField(GenerationField field) booleanisMultiTableInterface(String name) booleanbooleanisNodeIdField(GenerationField field) booleanisNodeType(String name) booleanbooleanisObject(FieldSpecification field) booleanbooleanbooleanbooleanisRecordType(String name) booleanisRecordType(FieldSpecification field) booleanbooleanbooleanisScalar(GenerationField field) booleanisSingleTableInterface(String name) booleanbooleanbooleanisType(FieldSpecification field) booleanbooleanisUnion(FieldSpecification field) booleannextTypeTableExists(GenerationField field, Set<String> seen) Simple method that tries to find a table reference the field's type.booleanbooleanreturnsList(ObjectField field) voidvalidate()Ensure that the definitions created in this class match database names where applicable.voidvalidate(boolean checkTypes) Ensure that the definitions created in this class match database names where applicable.
-
Constructor Details
-
ProcessedSchema
public ProcessedSchema(graphql.schema.idl.TypeDefinitionRegistry typeRegistry)
-
-
Method Details
-
nodeExists
public boolean nodeExists() -
validate
public void validate()Ensure that the definitions created in this class match database names where applicable. -
validate
public void validate(boolean checkTypes) Ensure that the definitions created in this class match database names where applicable. -
isType
- Returns:
- Does this name belong to a valid GraphQL type in the schema?
-
isType
- Returns:
- Does this field type belong to a valid GraphQL type in the schema?
-
getAllValidFieldTypeNames
- Returns:
- Set of all possible type or scalar names that a field can have in the schema.
-
getEnums
- Returns:
- Map of all the enums in the schema by name.
-
isEnum
- Returns:
- Does this name belong to an enum type in the schema?
-
isEnum
- Returns:
- Does this field point to an enum type in the schema?
-
isJavaMappedEnum
- Returns:
- Does this field point to an enum type in the schema and does it have the
GenerationDirective.ENUMdirective set?
-
getEnum
- Returns:
- Get an enum with this name.
-
getEnum
- Returns:
- Get the enum that this field points to.
-
getInterfaces
- Returns:
- Map of all the interfaces in the schema by name.
-
isInterface
- Returns:
- Does this name belong to an interface type in the schema?
-
isInterface
- Returns:
- Does this field point to an interface type in the schema?
-
isMultiTableInterface
- Returns:
- Does this field return a multi-table interface type in the schema?
-
isMultiTableInterface
- Returns:
- Does this name belong to a multi-table interface type in the schema?
-
isSingleTableInterface
- Returns:
- Does this field return a single table interface type in the schema?
-
isSingleTableInterface
- Returns:
- Does this name belong to a single table interface type in the schema?
-
isMultiTableField
- Returns:
- Does this field return rows from multiple tables?
-
getInterface
- Returns:
- Get an interface with this name.
-
getInterface
- Returns:
- Get the interface that this field points to.
-
getImplementationsForInterface
- Returns:
- Get the implementations for an interface given its name
-
getImplementationsForInterface
public List<ObjectDefinition> getImplementationsForInterface(InterfaceDefinition interfaceDefinition) - Returns:
- Get the implementations for an interface
-
getUnionSubTypes
- Returns:
- Get the ObjectDefinition for each Type in a Union given its name
-
getTypesFromInterfaceOrUnion
Returns the ObjectDefinition for each Type in a union given that the name supplied is a union. Otherwise, return the ObjectDefinition for all types that implements the given interface. -
getTypesFromInterfaceOrUnion
public Optional<List<ObjectDefinition>> getTypesFromInterfaceOrUnion(RecordObjectSpecification<?> definition) Returns the ObjectDefinition for each type implementing an interface or union given its definition -
getObjects
- Returns:
- Map of all the objects in the schema by name.
-
getUnreferencedObjects
- Returns:
- List of all the objects in the schema that are not referenced by an object field.
-
getEntities
- Returns:
- Map of all the types by name that have the federation directive @key set.
-
isEntity
-
getScalarTypes
- Returns:
- Set of all the scalar types in the schema.
-
isObject
- Returns:
- Does this name belong to an object type in the schema?
-
isObject
- Returns:
- Does this field point to an object type in the schema?
-
getObject
- Returns:
- Get an object with this name.
-
isNodeType
-
getNodeType
-
getNodeTypesWithTable
-
getObject
- Returns:
- Get the object that this field points to.
-
getObjectOrConnectionNode
- Returns:
- Get an object or connection node with this name.
-
getObjectOrConnectionNode
- Returns:
- Get the object or connection node that this field points to.
-
hasTableObject
- Returns:
- Does this name belong to an object type or connection node in the schema that is connected to a database table?
-
hasTableObject
- Returns:
- Does this field point to an object type or connection node in the schema that is connected to a database table?
-
implementsNode
- Returns:
- Does this name point to an object type in the schema which implements the Node interface?
-
implementsNode
- Returns:
- Does this field point to an object type in the schema which implements the Node interface?
-
implementsInterface
- Returns:
- Does this name point to an object type in the schema which implements the interface?
-
implementsInterface
- Returns:
- Does this field point to an object type in the schema which implements the interface?
-
isConnectionObject
- Returns:
- Does this name belong to a connection object type in the schema?
-
isConnectionObject
- Returns:
- Does this field point to a connection object type in the schema?
-
getConnectionObject
- Returns:
- Get a connection object with this name.
-
getConnectionObject
- Returns:
- Get the connection object that this field points to.
-
isEdgeObject
- Returns:
- Does this name belong to an edge object type in the schema?
-
getExceptions
- Returns:
- Map of all the exceptions in the schema by name.
-
isException
- Returns:
- Does this name belong to an exception type in the schema?
-
getException
- Returns:
- Get an exception with this name.
-
getInputTypes
- Returns:
- Map of all the input type objects in the schema by name.
-
isInputType
- Returns:
- Does this name belong to an input type in the schema?
-
isInputType
- Returns:
- Does this field point to an input type in the schema?
-
hasJOOQRecord
- Returns:
- Does this name point to a type that has a table set?
-
hasJOOQRecord
- Returns:
- Does this field point to a type that has a table set?
-
hasInputJOOQRecord
- Returns:
- Does this field point to an input type with a table set in the schema?
-
hasJavaRecord
- Returns:
- Does this type name point to a type with a Java record?
-
hasJavaRecord
- Returns:
- Does this field point to a type with a Java record set in the schema?
-
hasRecord
- Returns:
- Does this field point to an input type with a record set in the schema?
-
hasRecord
-
isOrderedMultiKeyQuery
- Returns:
- Is this an ordered multi-key query?
-
getInputType
- Returns:
- Get an input type with this name.
-
getInputType
- Returns:
- Get the input type that this field points to.
-
isUnion
- Returns:
- Does this name belong to a union type in the schema?
-
isUnion
- Returns:
- Does this field belong to a union type in the schema?
-
isExceptionUnion
- Returns:
- Does this name belong to a union type containing only error types?
-
isExceptionOrExceptionUnion
- Returns:
- Does this name belong to an exception type or a union type containing only error types?
-
isExceptionOrExceptionUnion
- Returns:
- Does this field belong to an exception type or a union type containing only error types?
-
getUnion
- Returns:
- Get a union type with this name.
-
getUnion
- Returns:
- Get a union type that this field points to.
-
getUnions
- Returns:
- Get all union types keyed by name.
-
isScalar
- Returns:
- Does this name belong to a scalar in the schema?
-
isScalar
- Returns:
- Is this field a scalar in the schema?
-
getQueryType
- Returns:
- The Query type.
-
getMutationType
- Returns:
- The Mutation type, if it exists.
-
getSchemaType
- Returns:
- The root schema type, if it exists.
-
isRecordType
- Returns:
- Does this name point to a type that may have a record set?
-
isRecordType
- Returns:
- Does this field point to a type that may have a record set?
-
getRecordType
- Returns:
- Find the type this field refers to.
-
getRecordType
- Returns:
- Find the type this field refers to.
-
federationEntitiesExist
public boolean federationEntitiesExist()- Returns:
- Does this schema import federation and have the _entities field?
-
getRecordTypes
- Returns:
- All types which could potentially have tables.
-
isNodeIdField
- Returns:
- Whether a field is a node ID field using NodeIdStrategy
-
getNodeTypeForNodeIdField
- Parameters:
field- theGenerationFieldto resolve the node type for- Returns:
- the corresponding
RecordObjectSpecification, ornullif not found
-
getNodeTypeForNodeIdFieldOrThrow
Finds node type for a node ID field. If not found an error is thrown.- Parameters:
field- TheGenerationFieldto resolve the node type for. The field must be a node ID field.- Returns:
- the corresponding
RecordObjectSpecification
-
getNodeConfigurationForNodeIdFieldOrThrow
Finds node type for a node ID field. If not found an error is thrown.- Parameters:
field- TheGenerationFieldto resolve the node type for. The field must be a node ID field.- Returns:
- the corresponding
RecordObjectSpecification
-
getNodeConfigurationForTypeOrThrow
Returns theNodeConfigurationfor the given type name, or throws if the@nodeconfiguration is missing.- Parameters:
typeName- the name of a node type in the schema- Returns:
- the node configuration for the type
-
getNodeConfigurationForTypeOrThrow
Returns theNodeConfigurationfor the given object, or throws if the@nodeconfiguration is missing.- Parameters:
object- the record object to retrieve the node configuration from- Returns:
- the node configuration for the object
-
isFederationService
- Returns:
- Is this field the federation _service field?
-
getResolvedOrderInput
- Returns:
- The resolved order input structure for the given orderInputField, with the enum definition
and the actual fields for the orderBy enum and direction.
Assumes the input type structure has been validated by
ProcessedDefinitionsValidator.
-
getPreviousTableObjectForObject
public RecordObjectSpecification<?> getPreviousTableObjectForObject(RecordObjectSpecification<?> object) - Returns:
- The closest table on or above this object. Assumes only one table can be associated with the object.
-
getPreviousTableObjectForField
- Returns:
- The closest table on or above this field. Assumes only one table can be associated with the object.
-
hasTableObjectForObject
- Returns:
- Returns whether the object has a table on or above it.
-
isObjectWithPreviousTableObject
-
isObjectOrConnectionNodeWithPreviousTableObject
-
isReferenceResolverField
-
invokesSubquery
Determines whether the field requires a correlated subquery in the generated database query.A correlated subquery is needed when resolving the field requires joining to a different table or fetching data that cannot be selected directly from the current table context.
Returns
truewhen any of the following conditions are met:- The field has explicit references via
@referencesdirective - The field's type maps to a different table than the current table (implicit reference)
- The field is a node ID reference field
- The field is a root query field with iterable-wrapped output and no parent table context
- Parameters:
field- the field to check for subquery requirementcurrentTable- the table context from which the field is being resolved- Returns:
trueif resolving this field requires a correlated subquery,falseotherwise
- The field has explicit references via
-
returnsList
-
findInputTables
Simple method that tries to find a table reference in the input records. This is not very robust, but we need this to not break existing things.- Returns:
- Table mapping for this context based on input records, if any exists.
-
inferDataTargetForMutation
Finds the target field which the returned data from mutation should be outputted. In the case of the mutation field being a wrapper type, this method will find the correct field inside the wrapper type which will contain data. This method assumes there is maximum one level of nesting.- Parameters:
initialTarget- The mutation field- Returns:
- The field which should contain the return data
-
isDeleteMutationWithReturning
-
isInsertMutationWithReturning
-
nextTypeTableExists
Simple method that tries to find a table reference the field's type.- Returns:
- Table mapping for this context based on the contents of the field's type records, if any exists.
-
getAllErrors
- Returns:
- List of all error types this type contains.
-
getErrorTypeDefinition
- Returns:
- The error type or union of error types with this name if it exists.
-
getExceptionDefinitions
- Returns:
- List of exception definitions that exists for this type name. If it is not a union, the list will only have one element.
-
getAllContextFields
-
getTransformableFields
- Returns:
- List of fields in the schema that may be used to generate transforms.
-
isFederationImported
public boolean isFederationImported()
-