Skip to main content

GraphQLScalarType <TInternal, TExternal>

Scalar Type Definition

The leaf values of any request and input values to arguments are Scalars (or Enums) and are defined with a name and a series of functions used to parse input from ast or variables and to ensure validity.

If a type’s serialize function does not return a value (i.e. it returns undefined) then an error will be raised and a null value will be returned in the response. If the serialize function returns null, then no error will be included in the response.

Example:

const OddType = new GraphQLScalarType({
name: 'Odd',
serialize(value) {
if (value % 2 === 1) {
return value;
}
}
});

Index

Constructors

constructor

Properties

astNode

astNode: Maybe<ScalarTypeDefinitionNode>

description

description: Maybe<string>

extensionASTNodes

extensionASTNodes: readonly ScalarTypeExtensionNode[]

extensions

extensions: Readonly<GraphQLScalarTypeExtensions>

name

name: string

parseLiteral

parseLiteral: GraphQLScalarLiteralParser<TInternal>

parseValue

parseValue: GraphQLScalarValueParser<TInternal>

serialize

serialize: GraphQLScalarSerializer<TExternal>

specifiedByURL

specifiedByURL: Maybe<string>

Accessors

[toStringTag]

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

Methods

toConfig

  • toConfig(): GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>
  • Returns GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>

toJSON

  • toJSON(): string
  • Returns string

toString

  • toString(): string
  • Returns string