Skip to main content

GraphQLObjectTypeImpl <TSource, TContext>

Object Type Definition

Almost all of the GraphQL types you define will be object types. Object types have a name, but most importantly describe their fields.

Example:

const AddressType = new GraphQLObjectTypeImpl({
name: 'Address',
fields: {
street: { type: GraphQLString },
number: { type: GraphQLInt },
formatted: {
type: GraphQLString,
resolve(obj) {
return obj.number + ' ' + obj.street
}
}
}
});

When two types need to refer to each other, or a type needs to refer to itself in a field, you can use a function expression (aka a closure or a thunk) to supply the fields lazily.

Example:

const PersonType = new GraphQLObjectTypeImpl({
name: 'Person',
fields: () => ({
name: { type: GraphQLString },
bestFriend: { type: PersonType },
})
});

Hierarchy

  • GraphQLEntityImpl
    • GraphQLObjectTypeImpl

Implements

  • GraphQLObjectType<TSource, TContext>

Index

Constructors

constructor

Properties

readonly[GRAPHQL_OBJECT_TYPE_SYMBOL]

[GRAPHQL_OBJECT_TYPE_SYMBOL]: true = true

readonly[GRAPHQL_VERSION_SYMBOL]

[GRAPHQL_VERSION_SYMBOL]: undefined = undefined

astNode

astNode: Maybe<ObjectTypeDefinitionNode>

description

description: Maybe<string>

extensionASTNodes

extensionASTNodes: readonly ObjectTypeExtensionNode[]

extensions

extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>

isTypeOf

isTypeOf: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>

name

name: string

Accessors

[toStringTag]

  • get [toStringTag](): string
  • Returns string

Methods

getFields

  • Returns GraphQLFieldMap<TSource, TContext>

getInterfaces

  • getInterfaces(): readonly GraphQLInterfaceType[]
  • Returns readonly GraphQLInterfaceType[]

toConfig

  • toConfig(): GraphQLObjectTypeNormalizedConfig<TSource, TContext>
  • Returns GraphQLObjectTypeNormalizedConfig<TSource, TContext>

toJSON

  • toJSON(): string
  • Returns string

toString

  • toString(): string
  • Returns string