ObjectTypeComposer
Main class that gets GraphQLObjectType
and provide ability to change them.
Static methods
static create()
static create<TSrc = any, TCtx = any>(
typeDef: ObjectTypeComposerDefinition<TSrc, TCtx>,
schemaComposer: SchemaComposer<TCtx>
): ObjectTypeComposer<TSrc, TCtx>
Create ObjectTypeComposer
with adding it by name to the SchemaComposer
.
static createTemp()
static createTemp<TSrc = any, TCtx = any>(
typeDef: ObjectTypeComposerDefinition<TSrc, TCtx>,
schemaComposer: SchemaComposer<TCtx>
): ObjectTypeComposer<TSrc, TCtx>
Create ObjectTypeComposer
without adding it to the SchemaComposer
.
This method may be useful in plugins, when you need to create type temporary.
Getters
List
List: ListComposer<ObjectTypeComposer<TSource, TContext>>;
Get Type wrapped in List modifier
const UserTC = schemaComposer.createObjectTC(`type User { name: String }`);
schemaComposer.Query.addFields({
users1: { type: UserTC.List }, // in SDL: users1: [User]
users2: { type: UserTC.NonNull.List }, // in SDL: users2: [User!]
users3: { type: UserTC.NonNull.List.NonNull } // in SDL: users2: [User!]!
});
NonNull
NonNull: NonNullComposer<ObjectTypeComposer<TSource, TContext>>;
Get Type wrapped in NonNull modifier
const UserTC = schemaComposer.createObjectTC(`type User { name: String }`);
schemaComposer.Query.addFields({
users1: { type: UserTC.List }, // in SDL: users1: [User]
users2: { type: UserTC.NonNull.List }, // in SDL: users2: [User!]!
users3: { type: UserTC.NonNull.List.NonNull } // in SDL: users2: [User!]!
});
Properties
schemaComposer
schemaComposer: SchemaComposer<TContext>;
Field methods
getFields()
getFields(): ObjectTypeComposerFieldConfigMap<TSource, TContext>
getFieldNames()
getFieldNames(): string[]
getField()
getField<TArgs = any>(
fieldName: string
): ObjectTypeComposerFieldConfig<TSource, TContext, TArgs>
hasField()
hasField(
fieldName: string
): boolean
setFields()
setFields(
fields: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>
): this
setField()
setField<TArgs = any>(
fieldName: string,
fieldConfig: ObjectTypeComposerFieldConfigDefinition<TSource, TContext, TArgs>
): this
addFields()
addFields(
newFields: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>
): this
Add new fields or replace existed in a GraphQL type
addNestedFields()
addNestedFields(
newFields: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>
): this
Add new fields or replace existed (where field name may have dots)
removeField()
removeField(
fieldNameOrArray: string | string[]
): this
Remove fields from type by name or array of names. You also may pass name in dot-notation, in such case will be removed nested field.
removeField('field1'); // remove 1 field
removeField(['field1', 'field2']); // remove 2 fields
removeField('field1.subField1'); // remove 1 nested field
removeOtherFields()
removeOtherFields(
fieldNameOrArray: string | string[]
): this
reorderFields()
reorderFields(
names: string[]
): this
extendField()
extendField<TArgs = any>(
fieldName: string,
partialFieldConfig: Partial<ObjectTypeComposerFieldConfigAsObjectDefinition<TSource, TContext, TArgs>>
): this
getFieldConfig()
getFieldConfig(
fieldName: string
): GraphQLFieldConfig<TSource, TContext>
getFieldType()
getFieldType(
fieldName: string
): GraphQLOutputType
getFieldTypeName()
getFieldTypeName(
fieldName: string
): string
getFieldTC()
getFieldTC(
fieldName: string
): ComposeNamedOutputType<TContext>
Automatically unwrap from List, NonNull, ThunkComposer It's important! Cause greatly helps to modify fields types in a real code without manual unwrap writing.
If you need to work with wrappers, you may use the following code:
TC.getField().type
// returns real wrapped TypeComposerTC.isFieldNonNull()
// checks is field NonNull or notTC.makeFieldNonNull()
// for wrapping in NonNullComposerTC.makeFieldNullable()
// for unwrapping from NonNullComposerTC.isFieldPlural()
// checks is field wrapped in ListComposer or notTC.makeFieldPlural()
// for wrapping in ListComposerTC.makeFieldNonPlural()
// for unwrapping from ListComposer
getFieldOTC()
getFieldOTC(
fieldName: string
): ObjectTypeComposer<TSource, TContext>
Alias for getFieldTC()
but returns statically checked ObjectTypeComposer.
If field have other type then error will be thrown.
isFieldNonNull()
isFieldNonNull(
fieldName: string
): boolean
makeFieldNonNull()
makeFieldNonNull(
fieldNameOrArray: string | string[]
): this
makeFieldNullable()
makeFieldNullable(
fieldNameOrArray: string | string[]
): this
isFieldPlural()
isFieldPlural(
fieldName: string
): boolean
makeFieldPlural()
makeFieldPlural(
fieldNameOrArray: string | string[]
): this
makeFieldNonPlural()
makeFieldNonPlural(
fieldNameOrArray: string | string[]
): this
deprecateFields()
deprecateFields(
fields: {
[fieldName: string]: string;
} | string[] | string
): this
Field Args methods
getFieldArgs()
getFieldArgs<TArgs = any>(
fieldName: string
): ObjectTypeComposerArgumentConfigMap<TArgs>
getFieldArgNames()
getFieldArgNames(
fieldName: string
): string[]
hasFieldArg()
hasFieldArg(
fieldName: string,
argName: string
): boolean
getFieldArg()
getFieldArg(
fieldName: string,
argName: string
): ObjectTypeComposerArgumentConfig
getFieldArgType()
getFieldArgType(
fieldName: string,
argName: string
): GraphQLInputType
getFieldArgTypeName()
getFieldArgTypeName(
fieldName: string,
argName: string
): string
getFieldArgTC()
getFieldArgTC(
fieldName: string,
argName: string
): ComposeNamedInputType<TContext>
Automatically unwrap from List, NonNull, ThunkComposer It's important! Cause greatly helps to modify args types in a real code without manual unwrap writing.
If you need to work with wrappers, you may use the following code:
isFieldArgPlural()
โ checks is arg wrapped in ListComposer or not
makeFieldArgPlural()
โ for arg wrapping in ListComposer
makeFieldArgNonPlural()
โ for arg unwrapping from ListComposer
isFieldArgNonNull()
โ checks is arg wrapped in NonNullComposer or not
makeFieldArgNonNull()
โ for arg wrapping in NonNullComposer
makeFieldArgNullable()
โ for arg unwrapping from NonNullComposer
getFieldArgITC()
getFieldArgITC(
fieldName: string,
argName: string
): InputTypeComposer<TContext>
Alias for getFieldArgTC()
but returns statically checked InputTypeComposer.
If field have other type then error will be thrown.
setFieldArgs()
setFieldArgs(
fieldName: string,
args: ObjectTypeComposerArgumentConfigMapDefinition<any>
): this
addFieldArgs()
addFieldArgs(
fieldName: string,
newArgs: ObjectTypeComposerArgumentConfigMapDefinition<any>
): this
setFieldArg()
setFieldArg(
fieldName: string,
argName: string,
argConfig: ObjectTypeComposerArgumentConfigDefinition
): this
removeFieldArg()
removeFieldArg(
fieldName: string,
argNameOrArray: string | string[]
): this
removeFieldOtherArgs()
removeFieldOtherArgs(
fieldName: string,
argNameOrArray: string | string[]
): this
isFieldArgPlural()
isFieldArgPlural(
fieldName: string,
argName: string
): boolean
makeFieldArgPlural()
makeFieldArgPlural(
fieldName: string,
argNameOrArray: string | string[]
): this
makeFieldArgNonPlural()
makeFieldArgNonPlural(
fieldName: string,
argNameOrArray: string | string[]
): this
isFieldArgNonNull()
isFieldArgNonNull(
fieldName: string,
argName: string
): boolean
makeFieldArgNonNull()
makeFieldArgNonNull(
fieldName: string,
argNameOrArray: string | string[]
): this
makeFieldArgNullable()
makeFieldArgNullable(
fieldName: string,
argNameOrArray: string | string[]
): this
Type methods
getType()
getType(): GraphQLObjectType
getTypePlural()
getTypePlural(): ListComposer<ObjectTypeComposer<TSource, TContext>>
getTypeNonNull()
getTypeNonNull(): NonNullComposer<ObjectTypeComposer<TSource, TContext>>
getTypeName()
getTypeName(): string
setTypeName()
setTypeName(
name: string
): this
getDescription()
getDescription(): string
setDescription()
setDescription(
description: string
): this
clone()
clone(
newTypeNameOrTC: string | ObjectTypeComposer<any, any>
): ObjectTypeComposer<TSource, TContext>
You may clone this type with a new provided name as string. Or you may provide a new TypeComposer which will get all cloned settings from this type.
cloneTo()
cloneTo(
anotherSchemaComposer: SchemaComposer<any>,
cloneMap: Map<any, any>
): ObjectTypeComposer<any, any>
Clone this type to another SchemaComposer. Also will be cloned all sub-types.
getIsTypeOf()
getIsTypeOf(): GraphQLIsTypeOfFn<TSource, TContext> | undefined | null
setIsTypeOf()
setIsTypeOf(
fn: GraphQLIsTypeOfFn<any, any> | null | undefined
): this
merge()
merge(
type: GraphQLObjectType | GraphQLInterfaceType | ObjectTypeComposer<any, any> | InterfaceTypeComposer<any, any>
): this
Merge fields and interfaces from provided GraphQLObjectType
, or ObjectTypeComposer
.
Also you may provide GraphQLInterfaceType
or InterfaceTypeComposer
for adding fields.
InputType methods
getInputType()
getInputType(): GraphQLInputObjectType
hasInputTypeComposer()
hasInputTypeComposer(): boolean
setInputTypeComposer()
setInputTypeComposer(
itc: InputTypeComposer<TContext>
): this
getInputTypeComposer()
getInputTypeComposer(
opts: ToInputTypeOpts
): InputTypeComposer<TContext>
getITC()
getITC(
opts: ToInputTypeOpts
): InputTypeComposer<TContext>
removeInputTypeComposer()
removeInputTypeComposer(): this
Resolver methods
getResolvers()
getResolvers(): Map<string, Resolver<any, TContext, any>>
hasResolver()
hasResolver(
name: string
): boolean
Returns existed Resolver by name.
Resolver may be additionally wrapped by middlewares. Eg:
async function authMiddleware(resolve, source, args, context, info) {
if (somehowCheckAuthInContext(context)) {
return resolve(source, args, context, info);
}
throw new Error('You must be authorized');
}
schemaComposer.Query.addFields({
userById: UserTC.getResolver('findById', [authMiddleware]),
userByIds: UserTC.getResolver('findByIds', [authMiddleware])
});
getResolver()
getResolver<TArgs = any>(
name: string,
middlewares: Array<ResolverMiddleware<TSource, TContext, TArgs>>
): Resolver<any, TContext, TArgs>
setResolver()
setResolver(
name: string,
resolver: Resolver<any, TContext>
): this
addResolver()
addResolver(
opts: Resolver<any, TContext> | ResolverDefinition<any, TContext>
): this
removeResolver()
removeResolver(
resolverName: string
): this
wrapResolver()
wrapResolver(
resolverName: string,
cbResolver: ResolverWrapCb<any, TSource, TContext>
): this
wrapResolverAs()
wrapResolverAs(
resolverName: string,
fromResolverName: string,
cbResolver: ResolverWrapCb<any, TSource, TContext>
): this
wrapResolverResolve()
wrapResolverResolve(
resolverName: string,
cbNextRp: ResolverNextRpCb<any, TContext>
): this
Interface methods
getInterfaces()
getInterfaces(): Array<InterfaceTypeComposerThunked<TSource, TContext>>
getInterfacesTypes()
getInterfacesTypes(): Array<GraphQLInterfaceType>
setInterfaces()
setInterfaces(
interfaces: ReadonlyArray<InterfaceTypeComposerDefinition<any, TContext>>
): this
hasInterface()
hasInterface(
iface: InterfaceTypeComposerDefinition<any, TContext>
): boolean
addInterface()
addInterface(
iface: InterfaceTypeComposerDefinition<any, TContext> | InterfaceTypeComposerThunked<any, TContext>
): this
addInterfaces()
addInterfaces(
ifaces: ReadonlyArray<InterfaceTypeComposerDefinition<any, TContext> | InterfaceTypeComposerThunked<any, TContext>>
): this
removeInterface()
removeInterface(
iface: InterfaceTypeComposerDefinition<any, TContext>
): this
Extensions methods
Extensions
is a property on type/field/arg definitions to pass private extra metadata.
It's used only on the server-side with the Code-First approach,
mostly for 3rd party server middlewares & plugins.
Property extensions
may contain private server metadata of any type (even functions)
and does not available via SDL.
@see https://github.com/graphql/graphql-js/issues/1527
@note
If you need to provide public metadata to clients then use directives
instead.
getExtensions()
getExtensions(): Extensions
setExtensions()
setExtensions(
extensions: Extensions | undefined
): this
extendExtensions()
extendExtensions(
extensions: Extensions
): this
clearExtensions()
clearExtensions(): this
getExtension()
getExtension(
extensionName: string
): unknown
hasExtension()
hasExtension(
extensionName: string
): boolean
setExtension()
setExtension(
extensionName: string,
value: unknown
): this
removeExtension()
removeExtension(
extensionName: string
): this
getFieldExtensions()
getFieldExtensions(
fieldName: string
): Extensions
setFieldExtensions()
setFieldExtensions(
fieldName: string,
extensions: Extensions
): this
extendFieldExtensions()
extendFieldExtensions(
fieldName: string,
extensions: Extensions
): this
clearFieldExtensions()
clearFieldExtensions(
fieldName: string
): this
getFieldExtension()
getFieldExtension(
fieldName: string,
extensionName: string
): unknown
hasFieldExtension()
hasFieldExtension(
fieldName: string,
extensionName: string
): boolean
setFieldExtension()
setFieldExtension(
fieldName: string,
extensionName: string,
value: unknown
): this
removeFieldExtension()
removeFieldExtension(
fieldName: string,
extensionName: string
): this
getFieldArgExtensions()
getFieldArgExtensions(
fieldName: string,
argName: string
): Extensions
setFieldArgExtensions()
setFieldArgExtensions(
fieldName: string,
argName: string,
extensions: Extensions
): this
extendFieldArgExtensions()
extendFieldArgExtensions(
fieldName: string,
argName: string,
extensions: Extensions
): this
clearFieldArgExtensions()
clearFieldArgExtensions(
fieldName: string,
argName: string
): this
getFieldArgExtension()
getFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string
): unknown
hasFieldArgExtension()
hasFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string
): boolean
setFieldArgExtension()
setFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string,
value: unknown
): this
removeFieldArgExtension()
removeFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string
): this
Directive methods
Directives provide the ability to work with public metadata which is available via SDL.
Directives can be used on type/field/arg definitions. The most famous directives are
@deprecated(reason: "...")
and @specifiedBy(url: "...")
which are present in GraphQL spec.
GraphQL spec allows to you add any own directives.
@example type Article @directive1 { name @directive2 comments(limit: Int @directive3) }
@note
If you need private metadata then use extensions
instead.
getDirectives()
getDirectives(): Array<Directive>
setDirectives()
setDirectives(
directives: Array<Directive>
): this
getDirectiveNames()
getDirectiveNames(): string[]
getDirectiveByName()
getDirectiveByName(
directiveName: string
): DirectiveArgs | undefined
Returns arguments of first found directive by name. If directive does not exists then will be returned undefined.
setDirectiveByName()
setDirectiveByName(
directiveName: string,
args: DirectiveArgs
): this
Set arguments of first found directive by name. If directive does not exists then will be created new one.
getDirectiveById()
getDirectiveById(
idx: number
): DirectiveArgs | undefined
getFieldDirectives()
getFieldDirectives(
fieldName: string
): Array<Directive>
setFieldDirectives()
setFieldDirectives(
fieldName: string,
directives: Array<Directive> | undefined
): this
getFieldDirectiveNames()
getFieldDirectiveNames(
fieldName: string
): string[]
getFieldDirectiveByName()
getFieldDirectiveByName(
fieldName: string,
directiveName: string
): DirectiveArgs | undefined
Returns arguments of first found directive by name. If directive does not exists then will be returned undefined.
setFieldDirectiveByName()
setFieldDirectiveByName(
fieldName: string,
directiveName: string,
args: DirectiveArgs
): this
Set arguments of first found directive by name. If directive does not exists then will be created new one.
getFieldDirectiveById()
getFieldDirectiveById(
fieldName: string,
idx: number
): DirectiveArgs | undefined
getFieldArgDirectives()
getFieldArgDirectives(
fieldName: string,
argName: string
): Array<Directive>
setFieldArgDirectives()
setFieldArgDirectives(
fieldName: string,
argName: string,
directives: Array<Directive>
): this
getFieldArgDirectiveNames()
getFieldArgDirectiveNames(
fieldName: string,
argName: string
): string[]
getFieldArgDirectiveByName()
getFieldArgDirectiveByName(
fieldName: string,
argName: string,
directiveName: string
): DirectiveArgs | undefined
Returns arguments of first found directive by name. If directive does not exists then will be returned undefined.
setFieldArgDirectiveByName()
setFieldArgDirectiveByName(
fieldName: string,
argName: string,
directiveName: string,
args: DirectiveArgs
): this
Set arguments of first found directive by name. If directive does not exists then will be created new one.
getFieldArgDirectiveById()
getFieldArgDirectiveById(
fieldName: string,
argName: string,
idx: number
): DirectiveArgs | undefined
Misc methods
addRelation()
addRelation<TArgs extends Record<string, any> = any>(
fieldName: string,
opts: Readonly<ObjectTypeComposerRelationOpts<any, TSource, TContext, TArgs>>
): this
getRelations()
getRelations(): ObjectTypeComposerRelationMap<any, TContext>
setRecordIdFn()
setRecordIdFn(
fn: ObjectTypeComposerGetRecordIdFn<TSource, TContext>
): this
hasRecordIdFn()
hasRecordIdFn(): boolean
getRecordIdFn()
getRecordIdFn(): ObjectTypeComposerGetRecordIdFn<TSource, TContext>
getRecordId()
getRecordId(
source: TSource,
args: Record<string, any>,
context: TContext
): string | number
Get function that returns record id, from provided object.
get()
get(
path: string | string[]
): TypeInPath<TContext> | void
getNestedTCs()
getNestedTCs(
opts: {
exclude?: string[];
},
passedTypes: Set<NamedTypeComposer<any>>
): Set<NamedTypeComposer<any>>
Returns all types which are used inside the current type
toSDL()
toSDL(
opts: SchemaPrinterOptions & {
deep?: boolean;
exclude?: string[];
}
): string
Prints SDL for current type. Or print with all used types if deep: true
option was provided.
Internal type definitions
ObjectTypeComposerDefinition
export type ObjectTypeComposerDefinition<TSource, TContext> =
| TypeAsString
| TypeDefinitionString
| ObjectTypeComposerAsObjectDefinition<TSource, TContext>
| Readonly<ObjectTypeComposer<TSource, TContext>>
| Readonly<GraphQLObjectType>;
ObjectTypeComposerAsObjectDefinition
export type ObjectTypeComposerAsObjectDefinition<TSource, TContext> = {
name: string;
interfaces?: null | ThunkWithSchemaComposer<
ReadonlyArray<InterfaceTypeComposerDefinition<any, TContext>>,
SchemaComposer<TContext>
>;
fields?: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>;
isTypeOf?: null | GraphQLIsTypeOfFn<TSource, TContext>;
description?: string | null;
isIntrospection?: boolean;
extensions?: Extensions;
directives?: Directive[];
};
ObjectTypeComposerFieldConfigMap
export type ObjectTypeComposerFieldConfigMap<TSource, TContext> = ObjMap<
ObjectTypeComposerFieldConfig<TSource, TContext>
>;
ObjectTypeComposerFieldConfigMapDefinition
export type ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext> = ObjMap<
ObjectTypeComposerFieldConfigDefinition<TSource, TContext>
>;
ObjectTypeComposerFieldConfigDefinition
export type ObjectTypeComposerFieldConfigDefinition<TSource, TContext, TArgs = any> =
| ThunkWithSchemaComposer<
ObjectTypeComposerFieldConfigAsObjectDefinition<TSource, TContext, TArgs>,
SchemaComposer<TContext>
>
| ThunkWithSchemaComposer<ComposeOutputTypeDefinition<TContext>, SchemaComposer<TContext>>;
ObjectTypeComposerFieldConfigAsObjectDefinition
// | Readonly<Resolver<any, TContext, any>>;
export type ObjectTypeComposerFieldConfigAsObjectDefinition<TSource, TContext, TArgs = any> = {
type: ThunkWithSchemaComposer<
ComposeOutputTypeDefinition<TContext> | Readonly<Resolver<any, TContext, any>>,
SchemaComposer<TContext>
>;
args?: ObjectTypeComposerArgumentConfigMapDefinition<TArgs>;
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
subscribe?: GraphQLFieldResolver<TSource, TContext>;
deprecationReason?: string | null;
description?: string | null;
extensions?: Extensions | undefined;
directives?: Directive[];
[key: string]: any;
};
ObjectTypeComposerFieldConfig
export type ObjectTypeComposerFieldConfig<TSource, TContext, TArgs = any> = {
type: ComposeOutputType<TContext>;
args?: ObjectTypeComposerArgumentConfigMap<TArgs>;
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
subscribe?: GraphQLFieldResolver<TSource, TContext>;
deprecationReason?: string | null;
description?: string | null;
astNode?: FieldDefinitionNode | null;
extensions?: Extensions;
directives?: Directive[];
[key: string]: any;
};
ObjectTypeComposerArgumentConfigMap
// Compose Args -----------------------------
export type ObjectTypeComposerArgumentConfigMap<TArgs = Record<string, any>> = Record<
keyof TArgs,
ObjectTypeComposerArgumentConfig
>;
ObjectTypeComposerArgumentConfigMapDefinition
export type ObjectTypeComposerArgumentConfigMapDefinition<TArgs = Record<string, any>> = Record<
keyof TArgs,
ObjectTypeComposerArgumentConfigDefinition
>;
ObjectTypeComposerArgumentConfigAsObjectDefinition
export type ObjectTypeComposerArgumentConfigAsObjectDefinition = {
type: ThunkWithSchemaComposer<ComposeInputTypeDefinition, SchemaComposer<any>>;
defaultValue?: any;
description?: string | null;
deprecationReason?: string | null;
extensions?: Extensions;
directives?: Directive[];
[key: string]: any;
};
ObjectTypeComposerArgumentConfig
export type ObjectTypeComposerArgumentConfig = {
type: ComposeInputType;
defaultValue?: any;
description?: string | null;
deprecationReason?: string | null;
astNode?: InputValueDefinitionNode | null;
extensions?: Extensions;
directives?: Directive[];
[key: string]: any;
};
ObjectTypeComposerArgumentConfigDefinition
export type ObjectTypeComposerArgumentConfigDefinition =
| ObjectTypeComposerArgumentConfigAsObjectDefinition
| ThunkWithSchemaComposer<ComposeInputTypeDefinition, SchemaComposer<any>>;
ObjectTypeComposerRelationMap
// RELATION -----------------------------
export type ObjectTypeComposerRelationMap<TSource, TContext> = {
[fieldName: string]: ObjectTypeComposerRelationOpts<any, TSource, TContext>;
};
ObjectTypeComposerRelationOpts
export type ObjectTypeComposerRelationOpts<
TRelationSource,
TSource,
TContext,
TArgs extends Record<string, any> = any
> =
| ObjectTypeComposerRelationOptsWithResolver<TRelationSource, TSource, TContext, TArgs>
| ObjectTypeComposerFieldConfigAsObjectDefinition<TSource, TContext, TArgs>;
ObjectTypeComposerRelationOptsWithResolver
export type ObjectTypeComposerRelationOptsWithResolver<
TRelationSource,
TSource,
TContext,
TArgs extends Record<string, any> = any
> = {
resolver: ThunkWithSchemaComposer<
Resolver<TRelationSource, TContext, TArgs>,
SchemaComposer<TContext>
>;
prepareArgs?: ObjectTypeComposerRelationArgsMapper<TSource, TContext, TArgs>;
projection?: ProjectionType;
description?: string | null;
deprecationReason?: string | null;
catchErrors?: boolean;
extensions?: Extensions;
directives?: Directive[];
};
ObjectTypeComposerRelationArgsMapperFn
export type ObjectTypeComposerRelationArgsMapperFn<
TSource,
TContext,
TArgs = Record<string, any>
> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => any;
ObjectTypeComposerRelationArgsMapper
export type ObjectTypeComposerRelationArgsMapper<
TSource,
TContext,
TArgs extends Record<string, any> = Record<string, any>
> = {
[argName in keyof TArgs]:
| { [key: string]: any }
| ObjectTypeComposerRelationArgsMapperFn<TSource, TContext, TArgs>
| null
| void
| string
| number
| any[];
};
ObjectTypeComposerGetRecordIdFn
export type ObjectTypeComposerGetRecordIdFn<TSource, TContext, TArgs = any> = (
source: TSource,
args?: TArgs,
context?: TContext
) => string;
ObjectTypeComposerThunked
export type ObjectTypeComposerThunked<TReturn, TContext> =
| ObjectTypeComposer<TReturn, TContext>
| ThunkComposer<ObjectTypeComposer<TReturn, TContext>, GraphQLObjectType>;