- Spec PR / RFC
- enabled only when using
experimentalExecuteIncrementally()
, use of a schema or operation with@defer
/@stream
directives withinexecute()
will now throw. - enable early execution with the new
enableEarlyExecution
configuration option forexperimentalExecuteIncrementally()
.
- Spec PR / RFC
- enable with the new
experimentalFragmentArguments
configuration option forparse()
. - new experimental
Kind.FRAGMENT_ARGUMENT
for visiting - new experimental
TypeInfo
methods and options for handling fragment arguments. - coerce AST via new function
coerceInputLiteral()
with experimental fragment variables argument (as opposed to deprecatedvalueFromAST()
function).
- Spec PR
- Schema definition will include only the proper root types.
graphql-js
now properly enforces that the schema's root types must be unique.
- Use external GraphQL values for the programmatic
defaultValue
property ofGraphQLArgument
andGraphQLInputField
objects rather than coerced internal default value. Introspection will then present the exact original default value rather than attempting to "uncoerce" internal input values, avoiding some rare cases in which default values within an introspected schema could differ slightly from the original SDL (e.g. #3501).
- New support for resolver functions returning async iterables.
- New
validateExecutionArgs()
,executeQueryOrMutationOrSubscriptionEvent()
, orexperimentalExecuteQueryOrMutationOrSubscriptionEvent()
helpers are available to perform GraphQL argument evaluation and/or manipulation and then manually continue with execution. - New
perEventExecutor
option allows specification of a custom executor for subscription source stream events, with the default option set to new helperexecuteSubscriptionEvent()
. - New
abortSignal
option tographql()
,execute()
, andsubscribe()
allows cancellation of these methods; theabortSignal
can also be passed to field resolvers to cancel asynchronous work that they initiate. - New
hideSuggestions
option added tographql()
,validate()
,execute()
, andsubscribe()
; thegetVariableValues()
,getArgumentValues()
,getDirectiveValues()
,coerceInputValue()
,coerceInputLiteral()
,collectFields()
helpers; theValidationContext
class, as well as the coercion methods for leaf types. The option hides suggestions! - New utility
findSchemaChanges()
can be used to find safe changes as well as the breaking and dangerous changes returned byfindBreakingChanges()
andfindDangerousChanges()
. The latter two functions are now deprecated. - New utility
coerceInputLiteral()
replacesvalueFromAST()
. - New utility
valueToLiteral()
converts from an external input value to a literal value. Custom scalars can define custom behavior by implementing an optional newvalueToLiteral()
method, otherwise a default conversion function will be used. - New utilities
validateInputValue()
andvalidateInputLiteral()
can be used to validate input values and literals, respectively. - New utility
replaceVariableValues()
can be used to replace variables within complex scalars uses as inputs. This allows variables embedded within complex scalars to use the correct default values. - New
coerceInputLiteral()
methods on custom scalar types can be used (along with the newvalueToLiteral()
method when required) to automatically convert literals to values, including any variables embedded within complex scalars. Embedded variables will (finally) receive the appropriate default values! TheparseLiteral()
methods have been deprecated. - New helper
printDirective()
function introduced. - New option to use symbols rather than strings as keys within
extensions
properties of the various GraphQL Schema elements.
- Changes to the
execute()
function:- Field resolvers that are still running after the function returns (e.g. when null-bubbling from a rejected asynchronous resolver leads to early return with additional still running asynchronous resolvers) will no longer trigger additional child resolvers.
- Changes to the
subscribe()
function:subscribe()
may now return a non-promise.- When a subscription root field errors,
subscribe()
now returns a well-formattedGraphQLError
rather than throwing.
- Changes to the
coerceInputValue()
helper:- On coercion failure, the function now will return early with
undefined
rather than collecting or throwing errors. If detailed error information is desired, use new utilityvalidateInputValue()
.
- On coercion failure, the function now will return early with
- Changes to Variable Values throughout the code base:
- Variable Values are now a dedicated type containing both the coerced values as before as well as the variable signature and provided source, so that variables embedded within complex scalars will be able to be properly replaced.
- The return type of
getVariableValues()
has been updated, as have the provided arguments togetArgumentValues()
,coerceInputLiteral()
, andcollectFields()
, andgetDirectiveValues()
.
- Changes to AST nodes:
- AST node properties have been optimized to use
undefined
rather than empty arrays.
- AST node properties have been optimized to use
- Enum Changes:
IntrospectionType
is now properly typed usingTypeKind
Enum.- The
Kind
enum has been changes from a TypeScript Enum to an object literal. AKind
type is still exported, such thattypeof Kind
is not the same as theKind
type.
- Change to
GraphQLSchema
configuration:- The
assumeValid
config property exported by theGraphQLSchema.toConfig()
method now passes through the original flag passed on creation of theGraphQLSchema
. Previously, theassumeValid
property would be totrue
if validation had been run, potentially concealing the original intent.
- The
valueFromAST()
is deprecated, usecoerceInputLiteral()
instead.parse()
methods of leaf types are deprecated, usecoerceInputValue()
instead.parseLiteral()
methods of leaf types are deprecated, usecoerceInputLiteral()
instead.serialize()
methods of leaf types are deprecated, usecoerceOutputValue()
instead.findBreakingChanges()
andfindDangerousChanges()
are deprecated, usefindSchemaChanges()
instead.
- Deprecated
graphql/subscription
module has been removed, usegraphql/execution
instead - Deprecated
getOperationRootType()
#3571 has been removed, useschema.getRootType()
instead. - Deprecated
assertValidName()
andisValidNameError()
has been removed, useassertName()
instead. - Deprecated custom
TypeInfo
argument forvalidate()
has been removed. - Deprecated custom
getFieldDefFn()
argument forTypeInfo
constructor has been removed. To customize field resolution, one can subclass theGraphQLSchema
class and override thegetField()
method. - Deprecated positional arguments for the
GraphQLError
constructor have been removed. - Deprecated distinct Enum types
KindEnum
,TokenKindEnum
, andDirectiveLocationEnum
have been removed. - Deprecated
getVisitFn()
helper function has been removed, usegetEnterLeaveForKind()
instead. - Deprecated
formatError()
andprintError()
helper functions have been removed, useerror.toString()
anderror.toJSON()
methods instead. - Deprecated positional arguments for
createSourceEventStream()
have been removed.