@graphql-tools/utils 7.8.0-alpha-4fedab51.0 → 7.8.0
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.cjs.js +20 -20
- package/es5/index.cjs.js.map +1 -1
- package/es5/index.esm.js +21 -21
- package/es5/index.esm.js.map +1 -1
- package/es5/loaders.d.ts +1 -6
- package/es5/package.json +1 -1
- package/es5/print-schema-with-directives.d.ts +1 -1
- package/index.cjs.js +10 -10
- package/index.cjs.js.map +1 -1
- package/index.esm.js +11 -11
- package/index.esm.js.map +1 -1
- package/loaders.d.ts +1 -6
- package/package.json +1 -1
- package/print-schema-with-directives.d.ts +1 -1
package/es5/loaders.d.ts
CHANGED
|
@@ -7,11 +7,7 @@ export interface Source {
|
|
|
7
7
|
rawSDL?: string;
|
|
8
8
|
location?: string;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
cacheable?<TPointer, TOptions>(fn: (pointer: TPointer, options?: TOptions) => PromiseLike<Source | never>, pointer: TPointer, options?: TOptions): Promise<Source | never>;
|
|
12
|
-
cacheableSync?<TPointer, TOptions>(fn: (pointer: TPointer, options?: TOptions) => Source | never, pointer: TPointer, options?: TOptions): Source | never;
|
|
13
|
-
}
|
|
14
|
-
export declare type SingleFileOptions = GraphQLParseOptions & GraphQLSchemaValidationOptions & BuildSchemaOptions & Cacheable & {
|
|
10
|
+
export declare type SingleFileOptions = GraphQLParseOptions & GraphQLSchemaValidationOptions & BuildSchemaOptions & {
|
|
15
11
|
cwd?: string;
|
|
16
12
|
};
|
|
17
13
|
export declare type WithList<T> = T | T[];
|
|
@@ -22,7 +18,6 @@ export declare type DocumentGlobPathPointer = string;
|
|
|
22
18
|
export declare type DocumentPointer = WithList<DocumentGlobPathPointer>;
|
|
23
19
|
export declare type DocumentPointerSingle = ElementOf<DocumentPointer>;
|
|
24
20
|
export interface Loader<TPointer = string, TOptions extends SingleFileOptions = SingleFileOptions> {
|
|
25
|
-
cacheable?: boolean;
|
|
26
21
|
loaderId(): string;
|
|
27
22
|
canLoad(pointer: TPointer, options?: TOptions): Promise<boolean>;
|
|
28
23
|
canLoadSync?(pointer: TPointer, options?: TOptions): boolean;
|
package/es5/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { GetDocumentNodeFromSchemaOptions, PrintSchemaWithDirectivesOptions } fr
|
|
|
3
3
|
export declare function getDocumentNodeFromSchema(schema: GraphQLSchema, options?: GetDocumentNodeFromSchemaOptions): DocumentNode;
|
|
4
4
|
export declare function printSchemaWithDirectives(schema: GraphQLSchema, options?: PrintSchemaWithDirectivesOptions): string;
|
|
5
5
|
export declare function astFromSchema(schema: GraphQLSchema, pathToDirectivesInExtensions: Array<string>): SchemaDefinitionNode | SchemaExtensionNode;
|
|
6
|
-
export declare function astFromDirective(directive: GraphQLDirective, schema
|
|
6
|
+
export declare function astFromDirective(directive: GraphQLDirective, schema?: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): DirectiveDefinitionNode;
|
|
7
7
|
export declare function getDirectiveNodes(entity: GraphQLSchema | GraphQLNamedType | GraphQLEnumValue, schema: GraphQLSchema, pathToDirectivesInExtensions: Array<string>): Array<DirectiveNode>;
|
|
8
8
|
export declare function getDeprecatableDirectiveNodes(entity: GraphQLArgument | GraphQLField<any, any> | GraphQLInputField, schema: GraphQLSchema, pathToDirectivesInExtensions: Array<string>): Array<DirectiveNode>;
|
|
9
9
|
export declare function astFromArg(arg: GraphQLArgument, schema: GraphQLSchema, pathToDirectivesInExtensions: Array<string>): InputValueDefinitionNode;
|
package/index.cjs.js
CHANGED
|
@@ -450,6 +450,13 @@ function getDocumentNodeFromSchema(schema, options = {}) {
|
|
|
450
450
|
const typesMap = schema.getTypeMap();
|
|
451
451
|
const schemaNode = astFromSchema(schema, pathToDirectivesInExtensions);
|
|
452
452
|
const definitions = schemaNode != null ? [schemaNode] : [];
|
|
453
|
+
const directives = schema.getDirectives();
|
|
454
|
+
for (const directive of directives) {
|
|
455
|
+
if (graphql.isSpecifiedDirective(directive)) {
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
definitions.push(astFromDirective(directive, schema, pathToDirectivesInExtensions));
|
|
459
|
+
}
|
|
453
460
|
for (const typeName in typesMap) {
|
|
454
461
|
const type = typesMap[typeName];
|
|
455
462
|
const isPredefinedScalar = graphql.isSpecifiedScalarType(type);
|
|
@@ -479,13 +486,6 @@ function getDocumentNodeFromSchema(schema, options = {}) {
|
|
|
479
486
|
throw new Error(`Unknown type ${type}.`);
|
|
480
487
|
}
|
|
481
488
|
}
|
|
482
|
-
const directives = schema.getDirectives();
|
|
483
|
-
for (const directive of directives) {
|
|
484
|
-
if (graphql.isSpecifiedDirective(directive)) {
|
|
485
|
-
continue;
|
|
486
|
-
}
|
|
487
|
-
definitions.push(astFromDirective(directive, schema, pathToDirectivesInExtensions));
|
|
488
|
-
}
|
|
489
489
|
return {
|
|
490
490
|
kind: graphql.Kind.DOCUMENT,
|
|
491
491
|
definitions,
|
|
@@ -892,7 +892,7 @@ function makeDirectiveNode(name, args, directive) {
|
|
|
892
892
|
function makeDirectiveNodes(schema, directiveValues) {
|
|
893
893
|
const directiveNodes = [];
|
|
894
894
|
Object.entries(directiveValues).forEach(([directiveName, arrayOrSingleValue]) => {
|
|
895
|
-
const directive = schema.getDirective(directiveName);
|
|
895
|
+
const directive = schema === null || schema === void 0 ? void 0 : schema.getDirective(directiveName);
|
|
896
896
|
if (Array.isArray(arrayOrSingleValue)) {
|
|
897
897
|
arrayOrSingleValue.forEach(value => {
|
|
898
898
|
directiveNodes.push(makeDirectiveNode(directiveName, value, directive));
|
|
@@ -1682,7 +1682,7 @@ function createNamedStub(name, type) {
|
|
|
1682
1682
|
return new constructor({
|
|
1683
1683
|
name,
|
|
1684
1684
|
fields: {
|
|
1685
|
-
|
|
1685
|
+
_fake: {
|
|
1686
1686
|
type: graphql.GraphQLString,
|
|
1687
1687
|
},
|
|
1688
1688
|
},
|
|
@@ -1705,7 +1705,7 @@ function isNamedStub(type) {
|
|
|
1705
1705
|
if (graphql.isObjectType(type) || graphql.isInterfaceType(type) || graphql.isInputObjectType(type)) {
|
|
1706
1706
|
const fields = type.getFields();
|
|
1707
1707
|
const fieldNames = Object.keys(fields);
|
|
1708
|
-
return fieldNames.length === 1 && fields[fieldNames[0]].name === '
|
|
1708
|
+
return fieldNames.length === 1 && fields[fieldNames[0]].name === '_fake';
|
|
1709
1709
|
}
|
|
1710
1710
|
return false;
|
|
1711
1711
|
}
|