From 0820be642c29bf7e18d494b186de0323da7f24f4 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 8 Nov 2021 16:53:12 +0200 Subject: [PATCH] Add devAssert about removal of positional arguments Fixes #3359 --- src/execution/execute.ts | 6 ++++++ src/execution/subscribe.ts | 7 +++++++ src/graphql.ts | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/src/execution/execute.ts b/src/execution/execute.ts index 4da5534530..585e2bbed7 100644 --- a/src/execution/execute.ts +++ b/src/execution/execute.ts @@ -165,6 +165,12 @@ export interface ExecutionArgs { * a GraphQLError will be thrown immediately explaining the invalid input. */ export function execute(args: ExecutionArgs): PromiseOrValue { + // Temporary for v15 to v16 migration. Remove in v17 + devAssert( + arguments.length < 2, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const { schema, document, variableValues, rootValue } = args; // If arguments are missing or incorrect, throw an error. diff --git a/src/execution/subscribe.ts b/src/execution/subscribe.ts index e42aefb4fa..805d9b2123 100644 --- a/src/execution/subscribe.ts +++ b/src/execution/subscribe.ts @@ -1,4 +1,5 @@ import { inspect } from '../jsutils/inspect'; +import { devAssert } from '../jsutils/devAssert'; import { isAsyncIterable } from '../jsutils/isAsyncIterable'; import { addPath, pathToArray } from '../jsutils/Path'; import type { Maybe } from '../jsutils/Maybe'; @@ -51,6 +52,12 @@ import { mapAsyncIterator } from './mapAsyncIterator'; export async function subscribe( args: ExecutionArgs, ): Promise | ExecutionResult> { + // Temporary for v15 to v16 migration. Remove in v17 + devAssert( + arguments.length < 2, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const { schema, document, diff --git a/src/graphql.ts b/src/graphql.ts index 03e6b95882..8d07bac9fc 100644 --- a/src/graphql.ts +++ b/src/graphql.ts @@ -1,4 +1,5 @@ import type { PromiseOrValue } from './jsutils/PromiseOrValue'; +import { devAssert } from './jsutils/devAssert'; import { isPromise } from './jsutils/isPromise'; import type { Maybe } from './jsutils/Maybe'; @@ -90,6 +91,12 @@ export function graphqlSync(args: GraphQLArgs): ExecutionResult { } function graphqlImpl(args: GraphQLArgs): PromiseOrValue { + // Temporary for v15 to v16 migration. Remove in v17 + devAssert( + arguments.length < 2, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const { schema, source,