@luvio/graphql-parser 0.150.5 → 0.150.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8445,6 +8445,22 @@ function assertValidSDL(documentAST) {
|
|
|
8445
8445
|
}).join('\n\n'));
|
|
8446
8446
|
}
|
|
8447
8447
|
}
|
|
8448
|
+
/**
|
|
8449
|
+
* Utility function which asserts a SDL document is valid by throwing an error
|
|
8450
|
+
* if it is invalid.
|
|
8451
|
+
*
|
|
8452
|
+
* @internal
|
|
8453
|
+
*/
|
|
8454
|
+
|
|
8455
|
+
function assertValidSDLExtension(documentAST, schema) {
|
|
8456
|
+
var errors = validateSDL(documentAST, schema);
|
|
8457
|
+
|
|
8458
|
+
if (errors.length !== 0) {
|
|
8459
|
+
throw new Error(errors.map(function (error) {
|
|
8460
|
+
return error.message;
|
|
8461
|
+
}).join('\n\n'));
|
|
8462
|
+
}
|
|
8463
|
+
}
|
|
8448
8464
|
|
|
8449
8465
|
/**
|
|
8450
8466
|
* Memoizes the provided three-argument function.
|
|
@@ -9890,6 +9906,37 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
9890
9906
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9891
9907
|
|
|
9892
9908
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9909
|
+
|
|
9910
|
+
/**
|
|
9911
|
+
* Produces a new schema given an existing schema and a document which may
|
|
9912
|
+
* contain GraphQL type extensions and definitions. The original schema will
|
|
9913
|
+
* remain unaltered.
|
|
9914
|
+
*
|
|
9915
|
+
* Because a schema represents a graph of references, a schema cannot be
|
|
9916
|
+
* extended without effectively making an entire copy. We do not know until it's
|
|
9917
|
+
* too late if subgraphs remain unchanged.
|
|
9918
|
+
*
|
|
9919
|
+
* This algorithm copies the provided schema, applying extensions while
|
|
9920
|
+
* producing the copy. The original schema remains unaltered.
|
|
9921
|
+
*
|
|
9922
|
+
* Accepts options as a third argument:
|
|
9923
|
+
*
|
|
9924
|
+
* - commentDescriptions:
|
|
9925
|
+
* Provide true to use preceding comments as the description.
|
|
9926
|
+
*
|
|
9927
|
+
*/
|
|
9928
|
+
function extendSchema(schema, documentAST, options) {
|
|
9929
|
+
assertSchema(schema);
|
|
9930
|
+
documentAST != null && documentAST.kind === Kind.DOCUMENT || devAssert(0, 'Must provide valid Document AST.');
|
|
9931
|
+
|
|
9932
|
+
if ((options === null || options === void 0 ? void 0 : options.assumeValid) !== true && (options === null || options === void 0 ? void 0 : options.assumeValidSDL) !== true) {
|
|
9933
|
+
assertValidSDLExtension(documentAST, schema);
|
|
9934
|
+
}
|
|
9935
|
+
|
|
9936
|
+
var schemaConfig = schema.toConfig();
|
|
9937
|
+
var extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options);
|
|
9938
|
+
return schemaConfig === extendedConfig ? schema : new GraphQLSchema(extendedConfig);
|
|
9939
|
+
}
|
|
9893
9940
|
/**
|
|
9894
9941
|
* @internal
|
|
9895
9942
|
*/
|
|
@@ -11477,6 +11524,7 @@ exports.buildASTSchema = buildASTSchema;
|
|
|
11477
11524
|
exports.buildSchema = buildSchema;
|
|
11478
11525
|
exports.defaultFieldResolver = defaultFieldResolver;
|
|
11479
11526
|
exports.execute = execute;
|
|
11527
|
+
exports.extendSchema = extendSchema;
|
|
11480
11528
|
exports.getNamedType = getNamedType;
|
|
11481
11529
|
exports.gql = gql;
|
|
11482
11530
|
exports.isObjectType = isObjectType;
|
package/dist/cjs/types/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLScalarType, execute, buildSchema, getNamedType, isObjectType, validateSchema, NameNode, GraphQLError, ObjectValueNode, defaultFieldResolver, type ASTNode, type DefinitionNode } from 'graphql';
|
|
1
|
+
import { GraphQLSchema, GraphQLScalarType, execute, buildSchema, extendSchema, getNamedType, isObjectType, validateSchema, NameNode, GraphQLError, ObjectValueNode, defaultFieldResolver, type ASTNode, type DefinitionNode } from 'graphql';
|
|
2
2
|
import { buildASTSchema } from 'graphql/utilities';
|
|
3
3
|
import { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode } from './ast';
|
|
4
4
|
export type { GraphQLObjectType, GraphQLInterfaceType, GraphQLDirective, GraphQLUnionType, GraphQLNamedType, } from 'graphql/type';
|
|
@@ -11,7 +11,7 @@ export type { AstResolver } from './gql';
|
|
|
11
11
|
/**
|
|
12
12
|
* @deprecated - Schema-backed adapters will use standard graphql types re-exported from @luvio/graphql
|
|
13
13
|
*/
|
|
14
|
-
export { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode, GraphQLSchema, GraphQLScalarType, NameNode, GraphQLError, ASTNode, DefinitionNode, ObjectValueNode, buildASTSchema, execute, buildSchema, getNamedType, isObjectType, validateSchema, defaultFieldResolver, };
|
|
14
|
+
export { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode, GraphQLSchema, GraphQLScalarType, NameNode, GraphQLError, ASTNode, DefinitionNode, ObjectValueNode, buildASTSchema, execute, buildSchema, extendSchema, getNamedType, isObjectType, validateSchema, defaultFieldResolver, };
|
|
15
15
|
/**
|
|
16
16
|
* @deprecated In favor of gql tagged template literal
|
|
17
17
|
*/
|
|
@@ -8443,6 +8443,22 @@ function assertValidSDL(documentAST) {
|
|
|
8443
8443
|
}).join('\n\n'));
|
|
8444
8444
|
}
|
|
8445
8445
|
}
|
|
8446
|
+
/**
|
|
8447
|
+
* Utility function which asserts a SDL document is valid by throwing an error
|
|
8448
|
+
* if it is invalid.
|
|
8449
|
+
*
|
|
8450
|
+
* @internal
|
|
8451
|
+
*/
|
|
8452
|
+
|
|
8453
|
+
function assertValidSDLExtension(documentAST, schema) {
|
|
8454
|
+
var errors = validateSDL(documentAST, schema);
|
|
8455
|
+
|
|
8456
|
+
if (errors.length !== 0) {
|
|
8457
|
+
throw new Error(errors.map(function (error) {
|
|
8458
|
+
return error.message;
|
|
8459
|
+
}).join('\n\n'));
|
|
8460
|
+
}
|
|
8461
|
+
}
|
|
8446
8462
|
|
|
8447
8463
|
/**
|
|
8448
8464
|
* Memoizes the provided three-argument function.
|
|
@@ -9888,6 +9904,37 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
9888
9904
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9889
9905
|
|
|
9890
9906
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9907
|
+
|
|
9908
|
+
/**
|
|
9909
|
+
* Produces a new schema given an existing schema and a document which may
|
|
9910
|
+
* contain GraphQL type extensions and definitions. The original schema will
|
|
9911
|
+
* remain unaltered.
|
|
9912
|
+
*
|
|
9913
|
+
* Because a schema represents a graph of references, a schema cannot be
|
|
9914
|
+
* extended without effectively making an entire copy. We do not know until it's
|
|
9915
|
+
* too late if subgraphs remain unchanged.
|
|
9916
|
+
*
|
|
9917
|
+
* This algorithm copies the provided schema, applying extensions while
|
|
9918
|
+
* producing the copy. The original schema remains unaltered.
|
|
9919
|
+
*
|
|
9920
|
+
* Accepts options as a third argument:
|
|
9921
|
+
*
|
|
9922
|
+
* - commentDescriptions:
|
|
9923
|
+
* Provide true to use preceding comments as the description.
|
|
9924
|
+
*
|
|
9925
|
+
*/
|
|
9926
|
+
function extendSchema(schema, documentAST, options) {
|
|
9927
|
+
assertSchema(schema);
|
|
9928
|
+
documentAST != null && documentAST.kind === Kind.DOCUMENT || devAssert(0, 'Must provide valid Document AST.');
|
|
9929
|
+
|
|
9930
|
+
if ((options === null || options === void 0 ? void 0 : options.assumeValid) !== true && (options === null || options === void 0 ? void 0 : options.assumeValidSDL) !== true) {
|
|
9931
|
+
assertValidSDLExtension(documentAST, schema);
|
|
9932
|
+
}
|
|
9933
|
+
|
|
9934
|
+
var schemaConfig = schema.toConfig();
|
|
9935
|
+
var extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options);
|
|
9936
|
+
return schemaConfig === extendedConfig ? schema : new GraphQLSchema(extendedConfig);
|
|
9937
|
+
}
|
|
9891
9938
|
/**
|
|
9892
9939
|
* @internal
|
|
9893
9940
|
*/
|
|
@@ -11466,4 +11513,4 @@ function parseAndVisit(source) {
|
|
|
11466
11513
|
return luvioDocumentNode;
|
|
11467
11514
|
}
|
|
11468
11515
|
|
|
11469
|
-
export { GraphQLError, GraphQLScalarType, GraphQLSchema, Kind, astResolver, buildASTSchema, buildSchema, defaultFieldResolver, execute, getNamedType, gql, isObjectType, isScalarType, parse, parseAndVisit, print, stripIgnoredCharacters, validateSchema, visit };
|
|
11516
|
+
export { GraphQLError, GraphQLScalarType, GraphQLSchema, Kind, astResolver, buildASTSchema, buildSchema, defaultFieldResolver, execute, extendSchema, getNamedType, gql, isObjectType, isScalarType, parse, parseAndVisit, print, stripIgnoredCharacters, validateSchema, visit };
|
package/dist/esm/types/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLScalarType, execute, buildSchema, getNamedType, isObjectType, validateSchema, NameNode, GraphQLError, ObjectValueNode, defaultFieldResolver, type ASTNode, type DefinitionNode } from 'graphql';
|
|
1
|
+
import { GraphQLSchema, GraphQLScalarType, execute, buildSchema, extendSchema, getNamedType, isObjectType, validateSchema, NameNode, GraphQLError, ObjectValueNode, defaultFieldResolver, type ASTNode, type DefinitionNode } from 'graphql';
|
|
2
2
|
import { buildASTSchema } from 'graphql/utilities';
|
|
3
3
|
import { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode } from './ast';
|
|
4
4
|
export type { GraphQLObjectType, GraphQLInterfaceType, GraphQLDirective, GraphQLUnionType, GraphQLNamedType, } from 'graphql/type';
|
|
@@ -11,7 +11,7 @@ export type { AstResolver } from './gql';
|
|
|
11
11
|
/**
|
|
12
12
|
* @deprecated - Schema-backed adapters will use standard graphql types re-exported from @luvio/graphql
|
|
13
13
|
*/
|
|
14
|
-
export { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode, GraphQLSchema, GraphQLScalarType, NameNode, GraphQLError, ASTNode, DefinitionNode, ObjectValueNode, buildASTSchema, execute, buildSchema, getNamedType, isObjectType, validateSchema, defaultFieldResolver, };
|
|
14
|
+
export { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode, GraphQLSchema, GraphQLScalarType, NameNode, GraphQLError, ASTNode, DefinitionNode, ObjectValueNode, buildASTSchema, execute, buildSchema, extendSchema, getNamedType, isObjectType, validateSchema, defaultFieldResolver, };
|
|
15
15
|
/**
|
|
16
16
|
* @deprecated In favor of gql tagged template literal
|
|
17
17
|
*/
|