TypeMapper
Type storage and type generator from Schema Definition Language
(SDL
).
This is slightly rewritten buildASTSchema
utility from graphql-js
that allows to create type from a string (SDL).
Static methods
static isOutputType()
static isOutputType(
type: any
): type is ComposeOutputType<any>
Check that provided TypeComposer is OutputType (Object, Scalar, Enum, Interface, Union). It may be wrapped in NonNull or List.
static isInputType()
static isInputType(
type: any
): type is ComposeInputType
Check that provided TypeComposer is InputType (InputObject, Scalar, Enum). It may be wrapped in NonNull or List.
static isTypeNameString()
static isTypeNameString(
str: string
): boolean
Check that string is a valid GraphQL Type name.
According to spec valid mask is /^[_A-Za-z][_0-9A-Za-z]*$/
.
static isTypeDefinitionString()
static isTypeDefinitionString(
str: string
): boolean
Checks that string is SDL definition of some type
eg. type Out { name: String! }
or input Filter { minAge: Int }
etc.
static isOutputTypeDefinitionString()
static isOutputTypeDefinitionString(
str: string
): boolean
Checks that string is OutputType SDL definition
eg. type Out { name: String! }
static isInputTypeDefinitionString()
static isInputTypeDefinitionString(
str: string
): boolean
Checks that string is InputType SDL definition
eg. input Filter { minAge: Int }
static isEnumTypeDefinitionString()
static isEnumTypeDefinitionString(
str: string
): boolean
Checks that string is EnumType SDL definition
eg. enum Sort { ASC DESC }
static isScalarTypeDefinitionString()
static isScalarTypeDefinitionString(
str: string
): boolean
Checks that string is ScalarType SDL definition
eg. scalar UInt
static isInterfaceTypeDefinitionString()
static isInterfaceTypeDefinitionString(
str: string
): boolean
Checks that string is InterfaceType SDL definition
eg. interface User { name: String }
Properties
schemaComposer
schemaComposer: SchemaComposer<TContext>;
Methods
convertGraphQLTypeToComposer()
convertGraphQLTypeToComposer(
type: GraphQLType
): AnyTypeComposer<TContext>
convertSDLWrappedTypeName()
convertSDLWrappedTypeName(
str: TypeWrappedString | TypeNameString
): GraphQLType | null
convertSDLTypeDefinition()
convertSDLTypeDefinition(
str: TypeDefinitionString
): NamedTypeComposer<TContext> | void
convertOutputTypeDefinition()
convertOutputTypeDefinition(
typeDef: Thunk<ComposeOutputTypeDefinition<any> | ObjectTypeComposerDefinition<any, any> | Readonly<Resolver<any, any>>>,
fieldName: string,
typeName: string
): ComposeOutputType<TContext> | void
convertOutputFieldConfig()
convertOutputFieldConfig<TSource>(
composeFC: Thunk<ObjectTypeComposerFieldConfigDefinition<TSource, TContext> | Readonly<Resolver<any, TContext>>>,
fieldName: string,
typeName: string
): ObjectTypeComposerFieldConfig<TSource, TContext>
convertOutputFieldConfigMap()
convertOutputFieldConfigMap<TSource>(
composeFields: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>,
typeName: string
): ObjectTypeComposerFieldConfigMap<TSource, TContext>
convertArgConfig()
convertArgConfig(
composeAC: Thunk<ObjectTypeComposerArgumentConfigDefinition>,
argName: string,
fieldName: string,
typeName: string
): ObjectTypeComposerArgumentConfig
convertArgConfigMap()
convertArgConfigMap(
composeArgsConfigMap: ObjectTypeComposerArgumentConfigMapDefinition<any>,
fieldName: string,
typeName: string
): ObjectTypeComposerArgumentConfigMap<any>
convertInputTypeDefinition()
convertInputTypeDefinition(
typeDef: Thunk<ComposeInputTypeDefinition>,
fieldName: string,
typeName: string
): ComposeInputType | void
convertInputFieldConfig()
convertInputFieldConfig(
composeIFC: Thunk<InputTypeComposerFieldConfigDefinition>,
fieldName: string,
typeName: string
): InputTypeComposerFieldConfig
convertInputFieldConfigMap()
convertInputFieldConfigMap(
composeFields: InputTypeComposerFieldConfigMapDefinition,
typeName: string
): InputTypeComposerFieldConfigMap
convertInterfaceTypeDefinition()
convertInterfaceTypeDefinition(
typeDef: InterfaceTypeComposerDefinition<any, TContext>
): InterfaceTypeComposerThunked<any, TContext>
parseTypesFromString()
parseTypesFromString(
str: string
): TypeStorage<string, NamedTypeComposer<TContext>>
Internal type definitions
TypeDefinitionString
/**
* Eg. `type Name { field: Int }`
*/
export type TypeDefinitionString = string;
TypeWrappedString
/**
* Eg. `Int`, `Int!`, `[Int]`
*/
export type TypeWrappedString = string;
TypeNameString
/**
* Eg. `Int`, `Float`
*/
export type TypeNameString = string;
TypeAsString
export type TypeAsString = TypeDefinitionString | TypeWrappedString | TypeNameString;