You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

graphql

Package Overview
Dependencies
Maintainers
7
Versions
279
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql - npm Package Compare versions

Comparing version

to
16.10.0-canary.pr.4192.22fb497360b20aa7bf7c12aa87d2420ff394b3a0

error/ErrorBehavior.d.ts

16

error/GraphQLError.d.ts

@@ -17,2 +17,14 @@ import type { Maybe } from '../jsutils/Maybe';

}
/**
* Custom formatted extensions
*
* @remarks
* Use a unique identifier name for your extension, for example the name of
* your library or project. Do not use a shortened identifier as this increases
* the risk of conflicts. We recommend you add at most one extension field,
* an object which can contain all the values you need.
*/
export interface GraphQLFormattedErrorExtensions {
[attributeName: string]: unknown;
}
export interface GraphQLErrorOptions {

@@ -126,5 +138,3 @@ nodes?: ReadonlyArray<ASTNode> | ASTNode | null;

*/
readonly extensions?: {
[key: string]: unknown;
};
readonly extensions?: GraphQLFormattedErrorExtensions;
}

@@ -131,0 +141,0 @@ /**

@@ -6,4 +6,6 @@ export { GraphQLError, printError, formatError } from './GraphQLError';

GraphQLErrorExtensions,
GraphQLFormattedErrorExtensions,
} from './GraphQLError';
export { syntaxError } from './syntaxError';
export { locatedError } from './locatedError';
export type { GraphQLErrorBehavior } from './ErrorBehavior';

@@ -5,2 +5,3 @@ import type { Maybe } from '../jsutils/Maybe';

import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
import type { GraphQLErrorBehavior } from '../error/ErrorBehavior';
import type { GraphQLFormattedError } from '../error/GraphQLError';

@@ -60,2 +61,3 @@ import { GraphQLError } from '../error/GraphQLError';

errors: Array<GraphQLError>;
errorBehavior: GraphQLErrorBehavior;
}

@@ -75,2 +77,3 @@ /**

data?: TData | null;
onError?: GraphQLErrorBehavior;
extensions?: TExtensions;

@@ -98,2 +101,11 @@ }

subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
/**
* Experimental. Set to NO_PROPAGATE to prevent error propagation. Set to ABORT to
* abort a request when any error occurs.
*
* Default: PROPAGATE
*
* @experimental
*/
onError?: GraphQLErrorBehavior;
}

@@ -100,0 +112,0 @@ /**

@@ -34,2 +34,4 @@ 'use strict';

var _ErrorBehavior = require('../error/ErrorBehavior.js');
var _GraphQLError = require('../error/GraphQLError.js');

@@ -226,3 +228,13 @@

subscribeFieldResolver,
onError,
} = args;
if (onError != null && !(0, _ErrorBehavior.isErrorBehavior)(onError)) {
return [
new _GraphQLError.GraphQLError(
'Unsupported `onError` value; supported values are `PROPAGATE`, `NO_PROPAGATE` and `ABORT`.',
),
];
}
let operation;

@@ -317,2 +329,4 @@ const fragments = Object.create(null);

errors: [],
errorBehavior:
onError !== null && onError !== void 0 ? onError : 'PROPAGATE',
};

@@ -554,2 +568,3 @@ }

variableValues: exeContext.variableValues,
errorBehavior: exeContext.errorBehavior,
};

@@ -559,6 +574,24 @@ }

function handleFieldError(error, returnType, exeContext) {
// If the field type is non-nullable, then it is resolved without any
// protection from errors, however it still properly locates the error.
if ((0, _definition.isNonNullType)(returnType)) {
if (exeContext.errorBehavior === 'PROPAGATE') {
// If the field type is non-nullable, then it is resolved without any
// protection from errors, however it still properly locates the error.
// Note: semantic non-null types are treated as nullable for the purposes
// of error handling.
if ((0, _definition.isNonNullType)(returnType)) {
throw error;
}
} else if (exeContext.errorBehavior === 'ABORT') {
// In this mode, any error aborts the request
throw error;
} else if (exeContext.errorBehavior === 'NO_PROPAGATE') {
// In this mode, the client takes responsibility for error handling, so we
// treat the field as if it were nullable.
/* c8 ignore next 6 */
} else {
false ||
(0, _invariant.invariant)(
false,
'Unexpected errorBehavior setting: ' +
(0, _inspect.inspect)(exeContext.errorBehavior),
);
} // Otherwise, error protection is applied, logging the error and resolving

@@ -596,6 +629,9 @@ // a null value for this field if one is encountered.

throw result;
} // If field type is NonNull, complete for inner type, and throw field error
} // If field type is non-nullable, complete for inner type, and throw field error
// if result is null.
if ((0, _definition.isNonNullType)(returnType)) {
if (
(0, _definition.isNonNullType)(returnType) ||
(0, _definition.isSemanticNonNullType)(returnType)
) {
const completed = completeValue(

@@ -612,3 +648,7 @@ exeContext,

throw new Error(
`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`,
`Cannot return null for ${
(0, _definition.isSemanticNonNullType)(returnType)
? 'semantically '
: ''
}non-nullable field ${info.parentType.name}.${info.fieldName}.`,
);

@@ -615,0 +655,0 @@ }

import type { Maybe } from './jsutils/Maybe';
import type { GraphQLErrorBehavior } from './error/ErrorBehavior';
import type { Source } from './language/source';

@@ -59,2 +60,11 @@ import type {

typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
/**
* Experimental. Set to NO_PROPAGATE to prevent error propagation. Set to ABORT to
* abort a request when any error occurs.
*
* Default: PROPAGATE
*
* @experimental
*/
onError?: GraphQLErrorBehavior;
}

@@ -61,0 +71,0 @@ export declare function graphql(args: GraphQLArgs): Promise<ExecutionResult>;

@@ -58,2 +58,3 @@ 'use strict';

typeResolver,
onError,
} = args; // Validate Schema

@@ -96,3 +97,4 @@

typeResolver,
onError,
});
}

@@ -44,2 +44,3 @@ /**

GraphQLNonNull,
GraphQLSemanticNonNull,
specifiedScalarTypes,

@@ -84,2 +85,3 @@ GraphQLInt,

isNonNullType,
isSemanticNonNullType,
isInputType,

@@ -109,2 +111,3 @@ isOutputType,

assertNonNullType,
assertSemanticNonNullType,
assertInputType,

@@ -134,2 +137,3 @@ assertOutputType,

GraphQLNullableType,
GraphQLNullableOutputType,
GraphQLNamedType,

@@ -262,2 +266,3 @@ GraphQLNamedInputType,

NonNullTypeNode,
SemanticNonNullTypeNode,
TypeSystemDefinitionNode,

@@ -357,5 +362,7 @@ SchemaDefinitionNode,

export type {
GraphQLErrorBehavior,
GraphQLErrorOptions,
GraphQLFormattedError,
GraphQLErrorExtensions,
GraphQLFormattedErrorExtensions,
} from './error/index';

@@ -414,2 +421,3 @@ export {

IntrospectionNonNullTypeRef,
IntrospectionSemanticNonNullTypeRef,
IntrospectionField,

@@ -416,0 +424,0 @@ IntrospectionInputValue,

@@ -168,2 +168,8 @@ 'use strict';

});
Object.defineProperty(exports, 'GraphQLSemanticNonNull', {
enumerable: true,
get: function () {
return _index.GraphQLSemanticNonNull;
},
});
Object.defineProperty(exports, 'GraphQLSkipDirective', {

@@ -631,2 +637,8 @@ enumerable: true,

});
Object.defineProperty(exports, 'assertSemanticNonNullType', {
enumerable: true,
get: function () {
return _index.assertSemanticNonNullType;
},
});
Object.defineProperty(exports, 'assertType', {

@@ -992,2 +1004,8 @@ enumerable: true,

});
Object.defineProperty(exports, 'isSemanticNonNullType', {
enumerable: true,
get: function () {
return _index.isSemanticNonNullType;
},
});
Object.defineProperty(exports, 'isSpecifiedDirective', {

@@ -994,0 +1012,0 @@ enumerable: true,

@@ -119,2 +119,3 @@ import type { Kind } from './kinds';

| NonNullTypeNode
| SemanticNonNullTypeNode
| SchemaDefinitionNode

@@ -166,2 +167,3 @@ | OperationTypeDefinitionNode

readonly definitions: ReadonlyArray<DefinitionNode>;
readonly tokenCount?: number | undefined;
}

@@ -353,3 +355,7 @@ export declare type DefinitionNode =

/** Type Reference */
export declare type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
export declare type TypeNode =
| NamedTypeNode
| ListTypeNode
| NonNullTypeNode
| SemanticNonNullTypeNode;
export interface NamedTypeNode {

@@ -370,2 +376,7 @@ readonly kind: Kind.NAMED_TYPE;

}
export interface SemanticNonNullTypeNode {
readonly kind: Kind.SEMANTIC_NON_NULL_TYPE;
readonly loc?: Location;
readonly type: NamedTypeNode | ListTypeNode;
}
/** Type System Definition */

@@ -372,0 +383,0 @@ export declare type TypeSystemDefinitionNode =

@@ -166,2 +166,3 @@ 'use strict';

NonNullType: ['type'],
SemanticNonNullType: ['type'],
SchemaDefinition: ['description', 'directives', 'operationTypes'],

@@ -168,0 +169,0 @@ OperationTypeDefinition: ['type'],

@@ -60,2 +60,3 @@ export { Source } from './source';

NonNullTypeNode,
SemanticNonNullTypeNode,
TypeSystemDefinitionNode,

@@ -62,0 +63,0 @@ SchemaDefinitionNode,

@@ -35,2 +35,3 @@ /**

NON_NULL_TYPE = 'NonNullType',
SEMANTIC_NON_NULL_TYPE = 'SemanticNonNullType',
/** Type System Definitions */

@@ -37,0 +38,0 @@ SCHEMA_DEFINITION = 'SchemaDefinition',

@@ -39,2 +39,3 @@ 'use strict';

Kind['NON_NULL_TYPE'] = 'NonNullType';
Kind['SEMANTIC_NON_NULL_TYPE'] = 'SemanticNonNullType';
Kind['SCHEMA_DEFINITION'] = 'SchemaDefinition';

@@ -41,0 +42,0 @@ Kind['OPERATION_TYPE_DEFINITION'] = 'OperationTypeDefinition';

@@ -106,2 +106,3 @@ 'use strict';

kind === _tokenKind.TokenKind.BANG ||
kind === _tokenKind.TokenKind.ASTERISK ||
kind === _tokenKind.TokenKind.DOLLAR ||

@@ -265,3 +266,3 @@ kind === _tokenKind.TokenKind.AMP ||

//
// Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
// Punctuator :: one of ! $ & ( ) * ... : = @ [ ] { | }

@@ -313,2 +314,11 @@ case 0x0021:

case 0x002a:
// *
return createToken(
lexer,
_tokenKind.TokenKind.ASTERISK,
position,
position + 1,
);
case 0x002e:

@@ -315,0 +325,0 @@ // .

@@ -152,2 +152,3 @@ import type { Maybe } from '../jsutils/Maybe';

constructor(source: string | Source, options?: ParseOptions);
get tokenCount(): number;
/**

@@ -317,2 +318,3 @@ * Converts a name lex token into a name parse node.

* - NonNullType
* - SemanticNonNullType
*/

@@ -319,0 +321,0 @@ parseTypeReference(): TypeNode;

@@ -32,3 +32,8 @@ 'use strict';

const parser = new Parser(source, options);
return parser.parseDocument();
const document = parser.parseDocument();
Object.defineProperty(document, 'tokenCount', {
enumerable: false,
value: parser.tokenCount,
});
return document;
}

@@ -104,2 +109,6 @@ /**

}
get tokenCount() {
return this._tokenCounter;
}
/**

@@ -676,2 +685,3 @@ * Converts a name lex token into a name parse node.

* - NonNullType
* - SemanticNonNullType
*/

@@ -701,2 +711,9 @@

if (this.expectOptionalToken(_tokenKind.TokenKind.ASTERISK)) {
return this.node(start, {
kind: _kinds.Kind.SEMANTIC_NON_NULL_TYPE,
type,
});
}
return type;

@@ -1542,6 +1559,6 @@ }

if (maxTokens !== undefined && token.kind !== _tokenKind.TokenKind.EOF) {
if (token.kind !== _tokenKind.TokenKind.EOF) {
++this._tokenCounter;
if (this._tokenCounter > maxTokens) {
if (maxTokens !== undefined && this._tokenCounter > maxTokens) {
throw (0, _syntaxError.syntaxError)(

@@ -1548,0 +1565,0 @@ this._lexer.source,

3

language/predicates.js

@@ -71,3 +71,4 @@ 'use strict';

node.kind === _kinds.Kind.LIST_TYPE ||
node.kind === _kinds.Kind.NON_NULL_TYPE
node.kind === _kinds.Kind.NON_NULL_TYPE ||
node.kind === _kinds.Kind.SEMANTIC_NON_NULL_TYPE
);

@@ -74,0 +75,0 @@ }

@@ -148,2 +148,5 @@ 'use strict';

},
SemanticNonNullType: {
leave: ({ type }) => type + '*',
},
// Type System Definitions

@@ -150,0 +153,0 @@ SchemaDefinition: {

@@ -9,2 +9,3 @@ /**

BANG = '!',
ASTERISK = '*',
DOLLAR = '$',

@@ -11,0 +12,0 @@ AMP = '&',

@@ -19,2 +19,3 @@ 'use strict';

TokenKind['BANG'] = '!';
TokenKind['ASTERISK'] = '*';
TokenKind['DOLLAR'] = '$';

@@ -21,0 +22,0 @@ TokenKind['AMP'] = '&';

@@ -148,6 +148,3 @@ 'use strict';

} else {
node = Object.defineProperties(
{},
Object.getOwnPropertyDescriptors(node),
);
node = { ...node };

@@ -154,0 +151,0 @@ for (const [editKey, editValue] of edits) {

{
"name": "graphql",
"version": "16.9.0",
"version": "16.10.0-canary.pr.4192.22fb497360b20aa7bf7c12aa87d2420ff394b3a0",
"description": "A Query Language and Runtime which can target any service.",

@@ -37,4 +37,5 @@ "license": "MIT",

"publishConfig": {
"tag": "latest"
}
}
"tag": "canary-pr-4192"
},
"deprecated": "You are using canary version build from https://github.com/graphql/graphql-js/pull/4192, no gurantees provided so please use your own discretion."
}

@@ -0,1 +1,3 @@

[![GraphQLConf 2024 Banner: September 10-12, San Francisco. Hosted by the GraphQL Foundation](https://github.com/user-attachments/assets/2d048502-e5b2-4e9d-a02a-50b841824de6)](https://graphql.org/conf/2024/?utm_source=github&utm_medium=graphql_js&utm_campaign=readme)
# GraphQL.js

@@ -2,0 +4,0 @@

@@ -5,2 +5,3 @@ import type { Maybe } from '../jsutils/Maybe';

import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
import type { GraphQLErrorBehavior } from '../error/ErrorBehavior';
import type {

@@ -47,2 +48,10 @@ EnumTypeDefinitionNode,

| GraphQLList<GraphQLType>
>
| GraphQLSemanticNonNull<
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<GraphQLOutputType>
>;

@@ -96,2 +105,8 @@ export declare function isType(type: unknown): type is GraphQLType;

): GraphQLNonNull<GraphQLType>;
export declare function isSemanticNonNullType(
type: unknown,
): type is GraphQLSemanticNonNull<GraphQLNullableOutputType>;
export declare function assertSemanticNonNullType(
type: unknown,
): GraphQLSemanticNonNull<GraphQLNullableOutputType>;
/**

@@ -130,2 +145,10 @@ * These types may be used as input types for arguments and directives.

| GraphQLList<GraphQLOutputType>
>
| GraphQLSemanticNonNull<
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<GraphQLOutputType>
>;

@@ -218,2 +241,35 @@ export declare function isOutputType(type: unknown): type is GraphQLOutputType;

/**
* Semantic-Non-Null Type Wrapper
*
* A semantic-non-null is a wrapping type which points to another type.
* Semantic-non-null types enforce that their values are never null unless
* caused by an error being raised. It is useful for fields which you can make
* a guarantee on non-nullability in a no-error case, for example when you know
* that a related entity must exist (but acknowledge that retrieving it may
* produce an error).
*
* Example:
*
* ```ts
* const RowType = new GraphQLObjectType({
* name: 'Row',
* fields: () => ({
* email: { type: new GraphQLSemanticNonNull(GraphQLString) },
* })
* })
* ```
* Note: the enforcement of non-nullability occurs within the executor.
*
* @experimental
*/
export declare class GraphQLSemanticNonNull<
T extends GraphQLNullableOutputType,
> {
readonly ofType: T;
constructor(ofType: T);
get [Symbol.toStringTag](): string;
toString(): string;
toJSON(): string;
}
/**
* These types wrap and modify other types

@@ -223,3 +279,4 @@ */

| GraphQLList<GraphQLType>
| GraphQLNonNull<GraphQLType>;
| GraphQLNonNull<GraphQLNullableType>
| GraphQLSemanticNonNull<GraphQLNullableOutputType>;
export declare function isWrappingType(

@@ -240,2 +297,12 @@ type: unknown,

| GraphQLList<GraphQLType>;
/**
* These types can all accept null as a value, and are suitable for output.
*/
export declare type GraphQLNullableOutputType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<GraphQLOutputType>;
export declare function isNullableType(

@@ -246,2 +313,5 @@ type: unknown,

export declare function getNullableType(type: undefined | null): void;
export declare function getNullableType<T extends GraphQLNullableOutputType>(
type: T | GraphQLNonNull<T> | GraphQLSemanticNonNull<T>,
): T;
export declare function getNullableType<T extends GraphQLNullableType>(

@@ -254,3 +324,3 @@ type: T | GraphQLNonNull<T>,

/**
* These named types do not include modifiers like List or NonNull.
* These named types do not include modifiers like List, NonNull, or SemanticNonNull
*/

@@ -522,2 +592,4 @@ export declare type GraphQLNamedType =

};
/** @experimental */
readonly errorBehavior: GraphQLErrorBehavior;
}

@@ -524,0 +596,0 @@ /**

@@ -7,2 +7,3 @@ 'use strict';

exports.GraphQLUnionType =
exports.GraphQLSemanticNonNull =
exports.GraphQLScalarType =

@@ -31,2 +32,3 @@ exports.GraphQLObjectType =

exports.assertScalarType = assertScalarType;
exports.assertSemanticNonNullType = assertSemanticNonNullType;
exports.assertType = assertType;

@@ -54,2 +56,3 @@ exports.assertUnionType = assertUnionType;

exports.isScalarType = isScalarType;
exports.isSemanticNonNullType = isSemanticNonNullType;
exports.isType = isType;

@@ -102,3 +105,4 @@ exports.isUnionType = isUnionType;

isListType(type) ||
isNonNullType(type)
isNonNullType(type) ||
isSemanticNonNullType(type)
);

@@ -233,2 +237,18 @@ }

}
function isSemanticNonNullType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLSemanticNonNull);
}
function assertSemanticNonNullType(type) {
if (!isSemanticNonNullType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(
type,
)} to be a GraphQL Semantic-Non-Null type.`,
);
}
return type;
}
/**

@@ -238,2 +258,3 @@ * These types may be used as input types for arguments and directives.

// Note: GraphQLSemanticNonNull is currently not allowed for input types
function isInputType(type) {

@@ -244,3 +265,5 @@ return (

isInputObjectType(type) ||
(isWrappingType(type) && isInputType(type.ofType))
(!isSemanticNonNullType(type) &&
isWrappingType(type) &&
isInputType(type.ofType))
);

@@ -424,3 +447,24 @@ }

/**
* These types wrap and modify other types
* Semantic-Non-Null Type Wrapper
*
* A semantic-non-null is a wrapping type which points to another type.
* Semantic-non-null types enforce that their values are never null unless
* caused by an error being raised. It is useful for fields which you can make
* a guarantee on non-nullability in a no-error case, for example when you know
* that a related entity must exist (but acknowledge that retrieving it may
* produce an error).
*
* Example:
*
* ```ts
* const RowType = new GraphQLObjectType({
* name: 'Row',
* fields: () => ({
* email: { type: new GraphQLSemanticNonNull(GraphQLString) },
* })
* })
* ```
* Note: the enforcement of non-nullability occurs within the executor.
*
* @experimental
*/

@@ -430,4 +474,41 @@

class GraphQLSemanticNonNull {
constructor(ofType) {
isNullableType(ofType) ||
(0, _devAssert.devAssert)(
false,
`Expected ${(0, _inspect.inspect)(
ofType,
)} to be a GraphQL nullable type.`,
);
isOutputType(ofType) ||
(0, _devAssert.devAssert)(
false,
`Expected ${(0, _inspect.inspect)(
ofType,
)} to be a GraphQL output type.`,
);
this.ofType = ofType;
}
get [Symbol.toStringTag]() {
return 'GraphQLSemanticNonNull';
}
toString() {
return String(this.ofType) + '*';
}
toJSON() {
return this.toString();
}
}
/**
* These types wrap and modify other types
*/
exports.GraphQLSemanticNonNull = GraphQLSemanticNonNull;
function isWrappingType(type) {
return isListType(type) || isNonNullType(type);
return isListType(type) || isNonNullType(type) || isSemanticNonNullType(type);
}

@@ -449,3 +530,3 @@

function isNullableType(type) {
return isType(type) && !isNonNullType(type);
return isType(type) && !isNonNullType(type) && !isSemanticNonNullType(type);
}

@@ -465,7 +546,9 @@

if (type) {
return isNonNullType(type) ? type.ofType : type;
return isNonNullType(type) || isSemanticNonNullType(type)
? type.ofType
: type;
}
}
/**
* These named types do not include modifiers like List or NonNull.
* These named types do not include modifiers like List, NonNull, or SemanticNonNull
*/

@@ -870,2 +953,3 @@

function isRequiredArgument(arg) {
// Note: input types cannot be SemanticNonNull
return isNonNullType(arg.type) && arg.defaultValue === undefined;

@@ -1373,3 +1457,4 @@ }

function isRequiredInputField(field) {
// Note: input types cannot be SemanticNonNull
return isNonNullType(field.type) && field.defaultValue === undefined;
}

@@ -16,2 +16,3 @@ export type { Path as ResponsePath } from '../jsutils/Path';

isNonNullType,
isSemanticNonNullType,
isInputType,

@@ -36,2 +37,3 @@ isOutputType,

assertNonNullType,
assertSemanticNonNullType,
assertInputType,

@@ -55,2 +57,3 @@ assertOutputType,

GraphQLNonNull,
GraphQLSemanticNonNull,
} from './definition';

@@ -66,2 +69,3 @@ export type {

GraphQLNullableType,
GraphQLNullableOutputType,
GraphQLNamedType,

@@ -68,0 +72,0 @@ GraphQLNamedInputType,

@@ -120,2 +120,8 @@ 'use strict';

});
Object.defineProperty(exports, 'GraphQLSemanticNonNull', {
enumerable: true,
get: function () {
return _definition.GraphQLSemanticNonNull;
},
});
Object.defineProperty(exports, 'GraphQLSkipDirective', {

@@ -325,2 +331,8 @@ enumerable: true,

});
Object.defineProperty(exports, 'assertSemanticNonNullType', {
enumerable: true,
get: function () {
return _definition.assertSemanticNonNullType;
},
});
Object.defineProperty(exports, 'assertType', {

@@ -482,2 +494,8 @@ enumerable: true,

});
Object.defineProperty(exports, 'isSemanticNonNullType', {
enumerable: true,
get: function () {
return _definition.isSemanticNonNullType;
},
});
Object.defineProperty(exports, 'isSpecifiedDirective', {

@@ -484,0 +502,0 @@ enumerable: true,

@@ -19,2 +19,3 @@ import type { GraphQLField, GraphQLNamedType } from './definition';

NON_NULL = 'NON_NULL',
SEMANTIC_NON_NULL = 'SEMANTIC_NON_NULL',
}

@@ -21,0 +22,0 @@ export { TypeKind };

@@ -26,2 +26,4 @@ 'use strict';

var _memoize = require('../jsutils/memoize1.js');
var _directiveLocation = require('../language/directiveLocation.js');

@@ -262,2 +264,6 @@

}
if ((0, _definition.isSemanticNonNullType)(type)) {
return TypeKind.SEMANTIC_NON_NULL;
}
/* c8 ignore next 3 */

@@ -425,3 +431,15 @@ // Not reachable, all possible types have been considered)

type: new _definition.GraphQLNonNull(__Type),
resolve: (field) => field.type,
args: {
includeSemanticNonNull: {
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
defaultValue: false,
},
},
resolve: (field, { includeSemanticNonNull }) => {
if (includeSemanticNonNull) {
return field.type;
}
return stripSemanticNonNullTypes(field.type);
},
},

@@ -440,3 +458,30 @@ isDeprecated: {

exports.__Field = __Field;
const stripSemanticNonNullTypes = (0, _memoize.memoize1)(
_stripSemanticNonNullTypes,
);
function _stripSemanticNonNullTypes(type) {
if ((0, _definition.isNonNullType)(type)) {
const convertedInner = stripSemanticNonNullTypes(type.ofType);
if (convertedInner === type.ofType) {
return type; // No change needed
}
return new _definition.GraphQLNonNull(convertedInner);
} else if ((0, _definition.isListType)(type)) {
const convertedInner = stripSemanticNonNullTypes(type.ofType);
if (convertedInner === type.ofType) {
return type; // No change needed
}
return new _definition.GraphQLList(convertedInner);
} else if ((0, _definition.isSemanticNonNullType)(type)) {
return stripSemanticNonNullTypes(type.ofType);
}
return type;
}
const __InputValue = new _definition.GraphQLObjectType({

@@ -520,2 +565,3 @@ name: '__InputValue',

TypeKind['NON_NULL'] = 'NON_NULL';
TypeKind['SEMANTIC_NON_NULL'] = 'SEMANTIC_NON_NULL';
})(TypeKind || (exports.TypeKind = TypeKind = {}));

@@ -565,2 +611,7 @@

},
SEMANTIC_NON_NULL: {
value: TypeKind.SEMANTIC_NON_NULL,
description:
'Indicates this type is a semantic-non-null. `ofType` is a valid field.',
},
},

@@ -567,0 +618,0 @@ });

@@ -178,5 +178,11 @@ 'use strict';

validateName(context, directive); // TODO: Ensure proper locations.
// Ensure the arguments are valid.
validateName(context, directive);
if (directive.locations.length === 0) {
context.reportError(
`Directive @${directive.name} must include 1 or more locations.`,
directive.astNode,
);
} // Ensure the arguments are valid.
for (const arg of directive.args) {

@@ -183,0 +189,0 @@ // Ensure they are named correctly.

@@ -44,2 +44,3 @@ 'use strict';

function astFromValue(value, type) {
// Note: input types cannot be SemanticNonNull
if ((0, _definition.isNonNullType)(type)) {

@@ -46,0 +47,0 @@ const astValue = astFromValue(value, type.ofType);

@@ -119,2 +119,22 @@ 'use strict';

if (typeRef.kind === _introspection.TypeKind.SEMANTIC_NON_NULL) {
const nullableRef = typeRef.ofType;
if (!nullableRef) {
throw new Error('Decorated type deeper than introspection query.');
}
const nullableType = (0, _definition.assertNullableType)(
getType(nullableRef),
);
if (!(0, _definition.isOutputType)(nullableType)) {
throw new Error(
'A semantic non-null wrapper must wrap an output type.',
);
}
return new _definition.GraphQLSemanticNonNull(nullableType);
}
return getNamedType(typeRef);

@@ -121,0 +141,0 @@ }

@@ -185,2 +185,7 @@ 'use strict';

return new _definition.GraphQLNonNull(replaceType(type.ofType));
}
if ((0, _definition.isSemanticNonNullType)(type)) {
// @ts-expect-error
return new _definition.GraphQLSemanticNonNull(replaceType(type.ofType));
} // @ts-expect-error FIXME

@@ -443,2 +448,12 @@

if (node.kind === _kinds.Kind.SEMANTIC_NON_NULL_TYPE) {
const wrapped = getWrappedType(node.type);
if (!(0, _definition.isOutputType)(wrapped)) {
throw new Error('A semantic non-null type cannot wrap an input type.');
}
return new _definition.GraphQLSemanticNonNull(wrapped);
}
return getNamedType(node);

@@ -445,0 +460,0 @@ }

@@ -433,2 +433,4 @@ 'use strict';

((0, _definition.isNonNullType)(newType) &&
isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) || // moving from nullable to semantic-non-null of the same underlying type is safe
((0, _definition.isSemanticNonNullType)(newType) &&
isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))

@@ -446,2 +448,15 @@ );

if ((0, _definition.isSemanticNonNullType)(oldType)) {
return (
// if they're both semantic-non-null, make sure the underlying types are compatible
((0, _definition.isSemanticNonNullType)(newType) &&
isChangeSafeForObjectOrInterfaceField(
oldType.ofType,
newType.ofType,
)) || // moving from semantic-non-null to non-null of the same underlying type is safe
((0, _definition.isNonNullType)(newType) &&
isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType))
);
}
return (

@@ -451,2 +466,4 @@ // if they're both named types, see if their names are equivalent

((0, _definition.isNonNullType)(newType) &&
isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) || // moving from nullable to semantic-non-null of the same underlying type is safe
((0, _definition.isSemanticNonNullType)(newType) &&
isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))

@@ -453,0 +470,0 @@ );

@@ -34,2 +34,7 @@ import type { Maybe } from '../jsutils/Maybe';

oneOf?: boolean;
/**
* Whether semantic non-null type wrappers should be included in the result.
* Default: false
*/
includeSemanticNonNull?: boolean;
}

@@ -135,2 +140,8 @@ /**

}
export interface IntrospectionSemanticNonNullTypeRef<
T extends IntrospectionTypeRef = IntrospectionTypeRef,
> {
readonly kind: 'SEMANTIC_NON_NULL';
readonly ofType: T;
}
export declare type IntrospectionTypeRef =

@@ -141,2 +152,5 @@ | IntrospectionNamedTypeRef

IntrospectionNamedTypeRef | IntrospectionListTypeRef
>
| IntrospectionSemanticNonNullTypeRef<
IntrospectionNamedTypeRef | IntrospectionListTypeRef
>;

@@ -143,0 +157,0 @@ export declare type IntrospectionOutputTypeRef =

@@ -20,2 +20,3 @@ 'use strict';

oneOf: false,
includeSemanticNonNull: false,
...options,

@@ -39,2 +40,3 @@ };

const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : '';
const includeSemanticNonNull = optionsWithDefault.includeSemanticNonNull;
return `

@@ -44,5 +46,5 @@ query IntrospectionQuery {

${schemaDescription}
queryType { name }
mutationType { name }
subscriptionType { name }
queryType { name kind }
mutationType { name kind }
subscriptionType { name kind }
types {

@@ -75,3 +77,7 @@ ...FullType

}
type {
type${
includeSemanticNonNull
? `(includeSemanticNonNull: ${includeSemanticNonNull})`
: ''
} {
...TypeRef

@@ -78,0 +84,0 @@ }

@@ -21,2 +21,3 @@ export { getIntrospectionQuery } from './getIntrospectionQuery';

IntrospectionNonNullTypeRef,
IntrospectionSemanticNonNullTypeRef,
IntrospectionField,

@@ -23,0 +24,0 @@ IntrospectionInputValue,

@@ -52,2 +52,5 @@ 'use strict';

return new _definition.GraphQLNonNull(replaceType(type.ofType));
} else if ((0, _definition.isSemanticNonNullType)(type)) {
// @ts-expect-error
return new _definition.GraphQLSemanticNonNull(replaceType(type.ofType));
} // @ts-expect-error FIXME: TS Conversion

@@ -54,0 +57,0 @@

@@ -26,2 +26,9 @@ 'use strict';

return isEqualType(typeA.ofType, typeB.ofType);
} // If either type is semantic-non-null, the other must also be semantic-non-null.
if (
(0, _definition.isSemanticNonNullType)(typeA) &&
(0, _definition.isSemanticNonNullType)(typeB)
) {
return isEqualType(typeA.ofType, typeB.ofType);
} // If either type is a list, the other must also be a list.

@@ -55,6 +62,20 @@

return false;
} // If superType is semantic-non-null, maybeSubType must be semantic-non-null or non-null.
if ((0, _definition.isSemanticNonNullType)(superType)) {
if (
(0, _definition.isNonNullType)(maybeSubType) ||
(0, _definition.isSemanticNonNullType)(maybeSubType)
) {
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
}
return false;
}
if ((0, _definition.isNonNullType)(maybeSubType)) {
// If superType is nullable, maybeSubType may be non-null or nullable.
if (
(0, _definition.isNonNullType)(maybeSubType) ||
(0, _definition.isSemanticNonNullType)(maybeSubType)
) {
// If superType is nullable, maybeSubType may be non-null, semantic-non-null, or nullable.
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);

@@ -61,0 +82,0 @@ } // If superType type is a list, maybeSubType type must also be a list.

@@ -24,2 +24,12 @@ 'use strict';

case _kinds.Kind.SEMANTIC_NON_NULL_TYPE: {
const innerType = typeFromAST(schema, typeNode.type);
if (!(0, _definition.isOutputType)(innerType)) {
throw new Error('A semantic non-null type must wrap an output type.');
}
return innerType && new _definition.GraphQLSemanticNonNull(innerType);
}
case _kinds.Kind.NAMED_TYPE:

@@ -26,0 +36,0 @@ return schema.getType(typeNode.name.value);

@@ -46,5 +46,6 @@ 'use strict';

function OverlappingFieldsCanBeMergedRule(context) {
// A memoization for when two fragments are compared "between" each other for
// conflicts. Two fragments may be compared many times, so memoizing this can
// dramatically improve the performance of this validator.
// A memoization for when fields and a fragment or two fragments are compared
// "between" each other for conflicts. Comparisons made be made many times,
// so memoizing this can dramatically improve the performance of this validator.
const comparedFieldsAndFragmentPairs = new OrderedPairSet();
const comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given

@@ -60,2 +61,3 @@ // selection set. Selection sets may be asked for this information multiple

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -141,2 +143,3 @@ context.getParentType(),

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -159,2 +162,3 @@ parentType,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -172,2 +176,3 @@ fieldMap,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -187,2 +192,3 @@ false,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -205,2 +211,3 @@ false,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -211,2 +218,19 @@ areMutuallyExclusive,

) {
// Memoize so the fields and fragments are not compared for conflicts more
// than once.
if (
comparedFieldsAndFragmentPairs.has(
fieldMap,
fragmentName,
areMutuallyExclusive,
)
) {
return;
}
comparedFieldsAndFragmentPairs.add(
fieldMap,
fragmentName,
areMutuallyExclusive,
);
const fragment = context.getFragment(fragmentName);

@@ -234,2 +258,3 @@

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -243,18 +268,2 @@ areMutuallyExclusive,

for (const referencedFragmentName of referencedFragmentNames) {
// Memoize so two fragments are not compared for conflicts more than once.
if (
comparedFragmentPairs.has(
referencedFragmentName,
fragmentName,
areMutuallyExclusive,
)
) {
continue;
}
comparedFragmentPairs.add(
referencedFragmentName,
fragmentName,
areMutuallyExclusive,
);
collectConflictsBetweenFieldsAndFragment(

@@ -264,2 +273,3 @@ context,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -278,2 +288,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -325,2 +336,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -338,2 +350,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -352,2 +365,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -366,2 +380,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -392,2 +407,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -405,2 +421,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -419,2 +436,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -435,2 +453,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -451,2 +470,3 @@ areMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -469,2 +489,3 @@ fieldMap,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -494,2 +515,3 @@ false, // within one collection is never mutually exclusive

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -514,2 +536,3 @@ parentFieldsAreMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -535,2 +558,3 @@ parentFieldsAreMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -605,2 +629,3 @@ parentFieldsAreMutuallyExclusive,

cachedFieldsAndFragmentNames,
comparedFieldsAndFragmentPairs,
comparedFragmentPairs,

@@ -676,2 +701,12 @@ areMutuallyExclusive,

if ((0, _definition.isSemanticNonNullType)(type1)) {
return (0, _definition.isSemanticNonNullType)(type2)
? doTypesConflict(type1.ofType, type2.ofType)
: true;
}
if ((0, _definition.isSemanticNonNullType)(type2)) {
return true;
}
if (

@@ -809,6 +844,10 @@ (0, _definition.isLeafType)(type1) ||

/**
* A way to keep track of pairs of things when the ordering of the pair does not matter.
* A way to keep track of pairs of things where the ordering of the pair
* matters.
*
* Provides a third argument for has/set to allow flagging the pair as
* weakly or strongly present within the collection.
*/
class PairSet {
class OrderedPairSet {
constructor() {

@@ -818,32 +857,51 @@ this._data = new Map();

has(a, b, areMutuallyExclusive) {
has(a, b, weaklyPresent) {
var _this$_data$get;
const [key1, key2] = a < b ? [a, b] : [b, a];
const result =
(_this$_data$get = this._data.get(key1)) === null ||
(_this$_data$get = this._data.get(a)) === null ||
_this$_data$get === void 0
? void 0
: _this$_data$get.get(key2);
: _this$_data$get.get(b);
if (result === undefined) {
return false;
} // areMutuallyExclusive being false is a superset of being true, hence if
// we want to know if this PairSet "has" these two with no exclusivity,
// we have to ensure it was added as such.
}
return areMutuallyExclusive ? true : areMutuallyExclusive === result;
return weaklyPresent ? true : weaklyPresent === result;
}
add(a, b, areMutuallyExclusive) {
const [key1, key2] = a < b ? [a, b] : [b, a];
add(a, b, weaklyPresent) {
const map = this._data.get(a);
const map = this._data.get(key1);
if (map === undefined) {
this._data.set(key1, new Map([[key2, areMutuallyExclusive]]));
this._data.set(a, new Map([[b, weaklyPresent]]));
} else {
map.set(key2, areMutuallyExclusive);
map.set(b, weaklyPresent);
}
}
}
/**
* A way to keep track of pairs of similar things when the ordering of the pair
* does not matter.
*/
class PairSet {
constructor() {
this._orderedPairSet = new OrderedPairSet();
}
has(a, b, weaklyPresent) {
return a < b
? this._orderedPairSet.has(a, b, weaklyPresent)
: this._orderedPairSet.has(b, a, weaklyPresent);
}
add(a, b, weaklyPresent) {
if (a < b) {
this._orderedPairSet.add(a, b, weaklyPresent);
} else {
this._orderedPairSet.add(b, a, weaklyPresent);
}
}
}

@@ -51,2 +51,13 @@ 'use strict';

);
} else if (selectionSet.selections.length === 0) {
const fieldName = node.name.value;
const typeStr = (0, _inspect.inspect)(type);
context.reportError(
new _GraphQLError.GraphQLError(
`Field "${fieldName}" of type "${typeStr}" must have at least one field selected.`,
{
nodes: node,
},
),
);
}

@@ -53,0 +64,0 @@ }

@@ -135,3 +135,3 @@ 'use strict';

);
}
} // Note: SemanticNonNull cannot happen on input.
},

@@ -138,0 +138,0 @@

@@ -95,2 +95,3 @@ 'use strict';

) {
// Note: SemanticNonNull cannot occur on input.
if (

@@ -97,0 +98,0 @@ (0, _definition.isNonNullType)(locationType) &&

@@ -13,3 +13,3 @@ 'use strict';

*/
const version = '16.9.0';
const version = '16.10.0';
/**

@@ -22,3 +22,3 @@ * An object containing the components of the GraphQL.js version string

major: 16,
minor: 9,
minor: 10,
patch: 0,

@@ -25,0 +25,0 @@ preReleaseTag: null,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet