@graphql-tools/utils 7.7.0-alpha-e3d43765.0 → 7.7.3

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.
package/es5/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './fix-schema-ast';
13
13
  export * from './parse-graphql-json';
14
14
  export * from './parse-graphql-sdl';
15
15
  export * from './get-user-types-from-schema';
16
+ export * from './create-schema-definition';
16
17
  export * from './build-operation-for-field';
17
18
  export * from './types';
18
19
  export * from './filterSchema';
package/es5/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedScalarType, isIntrospectionType, astFromValue, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, isSpecifiedDirective, GraphQLDeprecatedDirective, specifiedRules, validate, buildSchema, Source, TokenKind, visit, isTypeSystemDefinitionNode, buildClientSchema, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isSchema, isInputType, valueFromASTUntyped, isDirective, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, isCompositeType, doTypesOverlap, getOperationAST, getOperationRootType } from 'graphql';
1
+ import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, validate, buildSchema, Source, TokenKind, visit, isTypeSystemDefinitionNode, buildClientSchema, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isSchema, isInputType, valueFromASTUntyped, isDirective, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, isCompositeType, doTypesOverlap, getOperationAST, getOperationRootType } from 'graphql';
2
2
  import { __spreadArray, __read, __assign, __values, __awaiter, __generator, __extends } from 'tslib';
3
3
  import AggregateError from '@ardatan/aggregate-error';
4
4
  import { camelCase } from 'camel-case';
@@ -497,6 +497,23 @@ function getDocumentNodeFromSchema(schema, options) {
497
497
  var typesMap = schema.getTypeMap();
498
498
  var schemaNode = astFromSchema(schema, pathToDirectivesInExtensions);
499
499
  var definitions = schemaNode != null ? [schemaNode] : [];
500
+ var directives = schema.getDirectives();
501
+ try {
502
+ for (var directives_1 = __values(directives), directives_1_1 = directives_1.next(); !directives_1_1.done; directives_1_1 = directives_1.next()) {
503
+ var directive = directives_1_1.value;
504
+ if (isSpecifiedDirective(directive)) {
505
+ continue;
506
+ }
507
+ definitions.push(astFromDirective(directive, schema, pathToDirectivesInExtensions));
508
+ }
509
+ }
510
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
511
+ finally {
512
+ try {
513
+ if (directives_1_1 && !directives_1_1.done && (_a = directives_1.return)) _a.call(directives_1);
514
+ }
515
+ finally { if (e_1) throw e_1.error; }
516
+ }
500
517
  for (var typeName in typesMap) {
501
518
  var type = typesMap[typeName];
502
519
  var isPredefinedScalar = isSpecifiedScalarType(type);
@@ -526,23 +543,6 @@ function getDocumentNodeFromSchema(schema, options) {
526
543
  throw new Error("Unknown type " + type + ".");
527
544
  }
528
545
  }
529
- var directives = schema.getDirectives();
530
- try {
531
- for (var directives_1 = __values(directives), directives_1_1 = directives_1.next(); !directives_1_1.done; directives_1_1 = directives_1.next()) {
532
- var directive = directives_1_1.value;
533
- if (isSpecifiedDirective(directive)) {
534
- continue;
535
- }
536
- definitions.push(astFromDirective(directive, schema, pathToDirectivesInExtensions));
537
- }
538
- }
539
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
540
- finally {
541
- try {
542
- if (directives_1_1 && !directives_1_1.done && (_a = directives_1.return)) _a.call(directives_1);
543
- }
544
- finally { if (e_1) throw e_1.error; }
545
- }
546
546
  return {
547
547
  kind: Kind.DOCUMENT,
548
548
  definitions: definitions,
@@ -1356,6 +1356,29 @@ function getUserTypesFromSchema(schema) {
1356
1356
  return modelTypes;
1357
1357
  }
1358
1358
 
1359
+ function createSchemaDefinition(def, config) {
1360
+ var schemaRoot = {};
1361
+ if (def.query) {
1362
+ schemaRoot.query = def.query.toString();
1363
+ }
1364
+ if (def.mutation) {
1365
+ schemaRoot.mutation = def.mutation.toString();
1366
+ }
1367
+ if (def.subscription) {
1368
+ schemaRoot.subscription = def.subscription.toString();
1369
+ }
1370
+ var fields = Object.keys(schemaRoot)
1371
+ .map(function (rootType) { return (schemaRoot[rootType] ? rootType + ": " + schemaRoot[rootType] : null); })
1372
+ .filter(function (a) { return a; });
1373
+ if (fields.length) {
1374
+ return "schema { " + fields.join('\n') + " }";
1375
+ }
1376
+ if (config && config.force) {
1377
+ return " schema { query: Query } ";
1378
+ }
1379
+ return undefined;
1380
+ }
1381
+
1359
1382
  var operationVariables = [];
1360
1383
  var fieldTypeMap = new Map();
1361
1384
  function addOperationVariable(variable) {
@@ -1761,7 +1784,7 @@ function createNamedStub(name, type) {
1761
1784
  return new constructor({
1762
1785
  name: name,
1763
1786
  fields: {
1764
- __fake: {
1787
+ _fake: {
1765
1788
  type: GraphQLString,
1766
1789
  },
1767
1790
  },
@@ -1784,7 +1807,7 @@ function isNamedStub(type) {
1784
1807
  if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) {
1785
1808
  var fields = type.getFields();
1786
1809
  var fieldNames = Object.keys(fields);
1787
- return fieldNames.length === 1 && fields[fieldNames[0]].name === '__fake';
1810
+ return fieldNames.length === 1 && fields[fieldNames[0]].name === '_fake';
1788
1811
  }
1789
1812
  return false;
1790
1813
  }
@@ -4328,5 +4351,5 @@ function isDocumentNode(object) {
4328
4351
  return object && typeof object === 'object' && 'kind' in object && object.kind === Kind.DOCUMENT;
4329
4352
  }
4330
4353
 
4331
- export { MapperKind, SchemaDirectiveVisitor, SchemaVisitor, VisitSchemaKind, addTypes, appendObjectFields, argsToFieldConfigArgumentMap, argumentToArgumentConfig, asArray, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, cloneDirective, cloneSchema, cloneType, collectFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createStub, debugLog, fieldToFieldConfig, filterSchema, fixSchemaAst, fixWindowsPath, flattenArray, forEachDefaultValue, forEachField, getArgumentValues, getBuiltInForStub, getDeprecatableDirectiveNodes, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getUserTypesFromSchema, healSchema, healTypes, implementsAbstractType, inputFieldToFieldConfig, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isEqual, isNamedStub, isNotEqual, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printSchemaWithDirectives, pruneSchema, relocatedError, removeObjectFields, renameType, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, visitSchema };
4354
+ export { MapperKind, SchemaDirectiveVisitor, SchemaVisitor, VisitSchemaKind, addTypes, appendObjectFields, argsToFieldConfigArgumentMap, argumentToArgumentConfig, asArray, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, cloneDirective, cloneSchema, cloneType, collectFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createSchemaDefinition, createStub, debugLog, fieldToFieldConfig, filterSchema, fixSchemaAst, fixWindowsPath, flattenArray, forEachDefaultValue, forEachField, getArgumentValues, getBuiltInForStub, getDeprecatableDirectiveNodes, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getUserTypesFromSchema, healSchema, healTypes, implementsAbstractType, inputFieldToFieldConfig, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isEqual, isNamedStub, isNotEqual, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printSchemaWithDirectives, pruneSchema, relocatedError, removeObjectFields, renameType, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, visitSchema };
4332
4355
  //# sourceMappingURL=index.esm.js.map