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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindInputTables(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) getNodeType(String name) getNodeTypesWithTable(JOOQMapping table) getObject(FieldSpecification field) getOrderByFieldEnum(InputField orderInputField) getRecordType(String name) getRecordType(GenerationField field) Map<String,RecordObjectSpecification<? extends GenerationField>> getTypesFromInterfaceOrUnion(InterfaceDefinition interfaceDefinition) getTypesFromInterfaceOrUnion(UnionDefinition unionDefinition) getUnion(GenerationField field) getUnionSubTypes(String objectName) booleanbooleanbooleanhasJavaRecord(String typeName) booleanhasJavaRecord(GenerationField field) booleanhasJOOQRecord(String name) booleanhasJOOQRecord(GenerationField field) booleanhasRecord(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) booleanisConnectionObject(String name) booleanbooleanisEdgeObject(String name) booleanbooleanisEnum(GenerationField field) booleanisException(String name) booleanbooleanbooleanisExceptionUnion(String name) booleanisFederationService(GenerationField target) booleanisInputType(String name) booleanisInputType(FieldSpecification field) booleanisInterface(String name) booleanisInterface(GenerationField field) booleanbooleanisMultiTableField(GenerationField field) booleanisMultiTableInterface(String name) booleanbooleanisNodeIdField(GenerationField field) booleanIs this a node ID field in a non-node type that shares the same table with another node type?booleanbooleanisNodeType(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 Set<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
-
getTypesFromInterfaceOrUnion
-
getTypesFromInterfaceOrUnion
-
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.
-
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?
-
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.
-
hasEntitiesField
public boolean hasEntitiesField()- Returns:
- Does this schema use the _entities field?
-
getEntitiesField
- Returns:
- The _entities field in the Query type, if it exists.
-
getRecordTypes
- Returns:
- All types which could potentially have tables.
-
isNodeIdField
- Returns:
- Whether a field is a node ID field using NodeIdStrategy
-
isNodeIdReferenceField
-
isNodeIdForNodeTypeWithSameTable
Is this a node ID field in a non-node type that shares the same table with another node type?- Returns:
- Whether this is a field creating a node ID for another node type from the current table
-
getNodeTypeForNodeIdField
- Parameters:
field- theGenerationFieldto resolve the node type for- Returns:
- the corresponding
RecordObjectSpecification, ornullif not found
-
isFederationService
- Returns:
- Is this field the federation _service field?
-
getOrderByFieldEnum
- Returns:
- The enum definition representing the OrderByField of the given orderInputField
-
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.
-
hasTableObjectForObject
- Returns:
- Returns whether the object has a table on or above it.
-
isObjectWithPreviousTableObject
-
isObjectOrConnectionNodeWithPreviousTableObject
-
isReferenceResolverField
-
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.
-
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.
-