graphile-build 4.10.0 → 4.11.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/README.md +1 -0
- package/node8plus/SchemaBuilder.d.ts +29 -0
- package/node8plus/SchemaBuilder.js +21 -2
- package/node8plus/SchemaBuilder.js.flow +22 -1
- package/node8plus/SchemaBuilder.js.map +1 -1
- package/node8plus/makeNewBuild.js +71 -0
- package/node8plus/makeNewBuild.js.flow +120 -0
- package/node8plus/makeNewBuild.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ And please give some love to our featured sponsors 🤩:
|
|
|
37
37
|
<table><tr>
|
|
38
38
|
<td align="center"><a href="http://chads.website"><img src="https://graphile.org/images/sponsors/chadf.png" width="90" height="90" alt="Chad Furman" /><br />Chad Furman</a> *</td>
|
|
39
39
|
<td align="center"><a href="https://storyscript.com/?utm_source=postgraphile"><img src="https://graphile.org/images/sponsors/storyscript.png" width="90" height="90" alt="Storyscript" /><br />Storyscript</a> *</td>
|
|
40
|
+
<td align="center"><a href="https://surge.io/"><img src="https://graphile.org/images/sponsors/surge.png" width="90" height="90" alt="Surge.io" /><br />Surge.io</a> *</td>
|
|
40
41
|
<td align="center"><a href="https://postlight.com/?utm_source=graphile"><img src="https://graphile.org/images/sponsors/postlight.jpg" width="90" height="90" alt="Postlight" /><br />Postlight</a> *</td>
|
|
41
42
|
</tr></table>
|
|
42
43
|
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
GraphQLInputFieldConfigMap,
|
|
15
15
|
GraphQLInputFieldConfig,
|
|
16
16
|
GraphQLUnionTypeConfig,
|
|
17
|
+
GraphQLInterfaceTypeConfig,
|
|
17
18
|
} from "graphql";
|
|
18
19
|
import { EventEmitter } from "events";
|
|
19
20
|
|
|
@@ -182,6 +183,34 @@ export default class SchemaBuilder extends EventEmitter {
|
|
|
182
183
|
before?: Array<string>,
|
|
183
184
|
after?: Array<string>
|
|
184
185
|
): void;
|
|
186
|
+
hook<TSource, TContext>(
|
|
187
|
+
hookName: "GraphQLInterfaceType",
|
|
188
|
+
fn: Hook<GraphQLInterfaceTypeConfig<TSource, TContext>>,
|
|
189
|
+
provides?: Array<string>,
|
|
190
|
+
before?: Array<string>,
|
|
191
|
+
after?: Array<string>
|
|
192
|
+
): void;
|
|
193
|
+
hook<TSource, TContext>(
|
|
194
|
+
hookName: "GraphQLInterfaceType:fields",
|
|
195
|
+
fn: Hook<GraphQLFieldConfigMap<TSource, TContext>>,
|
|
196
|
+
provides?: Array<string>,
|
|
197
|
+
before?: Array<string>,
|
|
198
|
+
after?: Array<string>
|
|
199
|
+
): void;
|
|
200
|
+
hook<TSource, TContext>(
|
|
201
|
+
hookName: "GraphQLInterfaceType:fields:field",
|
|
202
|
+
fn: Hook<GraphQLFieldConfig<TSource, TContext>>,
|
|
203
|
+
provides?: Array<string>,
|
|
204
|
+
before?: Array<string>,
|
|
205
|
+
after?: Array<string>
|
|
206
|
+
): void;
|
|
207
|
+
hook(
|
|
208
|
+
hookName: "GraphQLInterfaceType:fields:field:args",
|
|
209
|
+
fn: Hook<GraphQLFieldConfigArgumentMap>,
|
|
210
|
+
provides?: Array<string>,
|
|
211
|
+
before?: Array<string>,
|
|
212
|
+
after?: Array<string>
|
|
213
|
+
): void;
|
|
185
214
|
hook(
|
|
186
215
|
hookName: "finalize",
|
|
187
216
|
fn: Hook<GraphQLSchema>,
|
|
@@ -96,7 +96,19 @@ class SchemaBuilder extends _events.default {
|
|
|
96
96
|
// - 'GraphQLUnionType' to add any root-level attributes, e.g. add a description
|
|
97
97
|
// - 'GraphQLUnionType:types' to add additional types to this union
|
|
98
98
|
GraphQLUnionType: [],
|
|
99
|
-
"GraphQLUnionType:types": []
|
|
99
|
+
"GraphQLUnionType:types": [],
|
|
100
|
+
// When creating a GraphQLInterfaceType via `newWithHooks`, we'll
|
|
101
|
+
// execute, the following hooks:
|
|
102
|
+
// - 'GraphQLInterfaceType' to add any root-level attributes, e.g. add a description
|
|
103
|
+
// - 'GraphQLInterfaceType:fields' to add additional fields to this interface type (is
|
|
104
|
+
// ran asynchronously and gets a reference to the final GraphQL Interface as
|
|
105
|
+
// `Self` in the context)
|
|
106
|
+
// - 'GraphQLInterfaceType:fields:field' to customise an individual field from above
|
|
107
|
+
// - 'GraphQLInterfaceType:fields:field:args' to customize the arguments to a field
|
|
108
|
+
GraphQLInterfaceType: [],
|
|
109
|
+
"GraphQLInterfaceType:fields": [],
|
|
110
|
+
"GraphQLInterfaceType:fields:field": [],
|
|
111
|
+
"GraphQLInterfaceType:fields:field:args": []
|
|
100
112
|
};
|
|
101
113
|
}
|
|
102
114
|
|
|
@@ -325,7 +337,14 @@ class SchemaBuilder extends _events.default {
|
|
|
325
337
|
__origin: `GraphQL built-in`,
|
|
326
338
|
isSchema: true
|
|
327
339
|
});
|
|
328
|
-
|
|
340
|
+
const hookedSchema = this.applyHooks(build, "finalize", schema, {}, "Finalising GraphQL schema");
|
|
341
|
+
const errors = build.graphql.validateSchema(hookedSchema);
|
|
342
|
+
|
|
343
|
+
if (errors && errors.length) {
|
|
344
|
+
throw new Error("GraphQL schema is invalid:\n" + errors.map(e => `- ` + e.message.replace(/\n/g, "\n ")).join("\n"));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this._generatedSchema = hookedSchema;
|
|
329
348
|
}
|
|
330
349
|
|
|
331
350
|
if (!this._generatedSchema) {
|
|
@@ -231,6 +231,19 @@ class SchemaBuilder extends EventEmitter {
|
|
|
231
231
|
// - 'GraphQLUnionType:types' to add additional types to this union
|
|
232
232
|
GraphQLUnionType: [],
|
|
233
233
|
"GraphQLUnionType:types": [],
|
|
234
|
+
|
|
235
|
+
// When creating a GraphQLInterfaceType via `newWithHooks`, we'll
|
|
236
|
+
// execute, the following hooks:
|
|
237
|
+
// - 'GraphQLInterfaceType' to add any root-level attributes, e.g. add a description
|
|
238
|
+
// - 'GraphQLInterfaceType:fields' to add additional fields to this interface type (is
|
|
239
|
+
// ran asynchronously and gets a reference to the final GraphQL Interface as
|
|
240
|
+
// `Self` in the context)
|
|
241
|
+
// - 'GraphQLInterfaceType:fields:field' to customise an individual field from above
|
|
242
|
+
// - 'GraphQLInterfaceType:fields:field:args' to customize the arguments to a field
|
|
243
|
+
GraphQLInterfaceType: [],
|
|
244
|
+
"GraphQLInterfaceType:fields": [],
|
|
245
|
+
"GraphQLInterfaceType:fields:field": [],
|
|
246
|
+
"GraphQLInterfaceType:fields:field:args": [],
|
|
234
247
|
};
|
|
235
248
|
}
|
|
236
249
|
|
|
@@ -488,13 +501,21 @@ class SchemaBuilder extends EventEmitter {
|
|
|
488
501
|
isSchema: true,
|
|
489
502
|
}
|
|
490
503
|
);
|
|
491
|
-
|
|
504
|
+
const hookedSchema = this.applyHooks(
|
|
492
505
|
build,
|
|
493
506
|
"finalize",
|
|
494
507
|
schema,
|
|
495
508
|
{},
|
|
496
509
|
"Finalising GraphQL schema"
|
|
497
510
|
);
|
|
511
|
+
const errors = build.graphql.validateSchema(hookedSchema);
|
|
512
|
+
if (errors && errors.length) {
|
|
513
|
+
throw new Error(
|
|
514
|
+
"GraphQL schema is invalid:\n" +
|
|
515
|
+
errors.map(e => `- ` + e.message.replace(/\n/g, "\n ")).join("\n")
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
this._generatedSchema = hookedSchema;
|
|
498
519
|
}
|
|
499
520
|
if (!this._generatedSchema) {
|
|
500
521
|
throw new Error("Schema generation failed");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/SchemaBuilder.js"],"names":["GraphQLSchema","graphql","debug","INDENT","SchemaBuilder","EventEmitter","constructor","options","Error","_busy","_watching","watchers","unwatchers","depth","hooks","build","inflection","init","finalize","GraphQLObjectType","GraphQLInputObjectType","GraphQLEnumType","GraphQLUnionType","_setPluginName","name","_currentPluginName","hook","hookName","fn","provides","before","after","displayName","length","join","push","relevantHooks","minIndex","minReason","maxIndex","maxReason","newProvides","newBefore","newAfter","describe","index","check","setMin","newMin","reason","setMax","newMax","forEach","oldHook","idx","oldProvides","oldBefore","oldAfter","some","dep","includes","splice","applyHooks","input","context","debugStr","repeat","newObj","hookDisplayName","previousHookName","status","currentHookName","previousHookEvent","currentHookEvent","oldObj","console","warn","Object","assign","registerWatcher","listen","unlisten","createBuild","initialBuild","scope","keys","filter","key","freeze","buildSchema","_generatedSchema","schema","newWithHooks","directives","specifiedDirectives","__origin","isSchema","watchSchema","listener","_explicitSchemaListener","ignoreChangeTriggers","triggerChange","emit","e","error","on","unwatchSchema","e2","removeListener"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAOA;;;;;;;;AAWA,MAAM;AAAEA,EAAAA;AAAF,IAAoBC,OAA1B;AAEA,MAAMC,KAAK,GAAG,oBAAa,kBAAb,CAAd;AAEA,MAAMC,MAAM,GAAG,IAAf;;AA+GA,MAAMC,aAAN,SAA4BC,eAA5B,CAAyC;AAgBvCC,EAAAA,WAAW,CAACC,OAAD,EAAmB;AAC5B;AAEA,SAAKA,OAAL,GAAeA,OAAf;;AACA,QAAI,CAACA,OAAL,EAAc;AACZ,YAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;AACD;;AAED,SAAKC,KAAL,GAAa,KAAb;AACA,SAAKC,SAAL,GAAiB,KAAjB;AAEA,SAAKC,QAAL,GAAgB,EAAhB;AACA,SAAKC,UAAL,GAAkB,EAAlB,CAZ4B,CAc5B;;AACA,SAAKC,KAAL,GAAa,CAAC,CAAd;AAEA,SAAKC,KAAL,GAAa;AACX;AACA;AACAC,MAAAA,KAAK,EAAE,EAHI;AAKX;AACA;AACAC,MAAAA,UAAU,EAAE,EAPD;AASX;AACA;AACA;AACAC,MAAAA,IAAI,EAAE,EAZK;AAcX;AACA;AACA;AACAC,MAAAA,QAAQ,EAAE,EAjBC;AAmBX;AACAlB,MAAAA,aAAa,EAAE,EApBJ;AAsBX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAmB,M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AG,KAAKC,uBAAtB;AACA,WAAKA,uBAAL,GAA+B,IAA/B;;AACA,UAAID,QAAJ,EAAc;AACZ,aAAKU,cAAL,CAAoB,QAApB,EAA8BV,QAA9B;AACD;;AACD,UAAI,KAAKG,aAAT,EAAwB;AACtB,aAAK,MAAMzE,EAAX,IAAiB,KAAKhB,UAAtB,EAAkC;AAChC,gBAAMgB,EAAE,CAAC,KAAKyE,aAAN,CAAR;AACD;AACF;;AACD,WAAKA,aAAL,GAAqB,IAArB;AACA,WAAK3F,SAAL,GAAiB,KAAjB;AACD,KAbD,SAaU;AACR,WAAKD,KAAL,GAAa,KAAb;AACD;AACF;;AA3csC;;eA8c1BL,a","sourcesContent":["// @flow\nimport debugFactory from \"debug\";\nimport makeNewBuild from \"./makeNewBuild\";\nimport { bindAll } from \"./utils\";\nimport * as graphql from \"graphql\";\nimport type {\n GraphQLType,\n GraphQLNamedType,\n GraphQLInterfaceType,\n GraphQLObjectTypeConfig,\n} from \"graphql\";\nimport EventEmitter from \"events\";\n// TODO: when we move to TypeScript, change this to:\n// import { EventEmitter } from \"events\";\nimport type {\n simplifyParsedResolveInfoFragmentWithType,\n parseResolveInfo,\n} from \"graphql-parse-resolve-info\";\nimport type { GraphQLResolveInfo } from \"graphql/type/definition\";\nimport type resolveNode from \"./resolveNode\";\n\nimport type { FieldWithHooksFunction } from \"./makeNewBuild\";\nconst { GraphQLSchema } = graphql;\n\nconst debug = debugFactory(\"graphile-builder\");\n\nconst INDENT = \" \";\n\nexport type Options = {\n [string]: mixed,\n};\n\nexport type Plugin = (\n builder: SchemaBuilder,\n options: Options\n) => Promise<void> | void;\n\ntype TriggerChangeType = () => void;\n\nexport type DataForType = {\n [string]: Array<mixed>,\n};\n\nexport type Build = {|\n graphileBuildVersion: string,\n graphql: *,\n parseResolveInfo: parseResolveInfo,\n simplifyParsedResolveInfoFragmentWithType: simplifyParsedResolveInfoFragmentWithType,\n // DEPRECATED: getAliasFromResolveInfo: (resolveInfo: GraphQLResolveInfo) => string,\n getSafeAliasFromResolveInfo: (resolveInfo: GraphQLResolveInfo) => string,\n getSafeAliasFromAlias: (alias: string) => string,\n resolveAlias(\n data: {},\n _args: mixed,\n _context: mixed,\n resolveInfo: GraphQLResolveInfo\n ): string,\n addType(type: GraphQLNamedType, origin?: ?string): void,\n getTypeByName(typeName: string): ?GraphQLType,\n extend<Obj1: *, Obj2: *>(base: Obj1, extra: Obj2, hint?: string): Obj1 & Obj2,\n newWithHooks<T: GraphQLNamedType | GraphQLSchema, ConfigType: *>(\n Class<T>,\n spec: ConfigType,\n scope: Scope,\n performNonEmptyFieldsCheck?: boolean\n ): ?T,\n fieldDataGeneratorsByType: Map<*, *>, // @deprecated - use fieldDataGeneratorsByFieldNameByType instead\n fieldDataGeneratorsByFieldNameByType: Map<*, *>,\n fieldArgDataGeneratorsByFieldNameByType: Map<*, *>,\n inflection: {\n // eslint-disable-next-line flowtype/no-weak-types\n [string]: (...args: Array<any>) => string,\n },\n wrapDescription: (\n description: string,\n position: \"root\" | \"type\" | \"field\" | \"arg\"\n ) => string,\n swallowError: (e: Error) => void,\n // resolveNode: EXPERIMENTAL, API might change!\n resolveNode: resolveNode,\n status: {\n currentHookName: ?string,\n currentHookEvent: ?string,\n },\n scopeByType: Map<GraphQLType, Scope>,\n|};\n\nexport type BuildExtensionQuery = {|\n $$isQuery: Symbol,\n|};\n\nexport type Scope = {\n __origin: ?string,\n [string]: mixed,\n};\n\nexport type Context = {|\n scope: Scope,\n type: string,\n [string]: mixed,\n|};\n\ntype DataGeneratorFunction = () => {};\n\nexport type ContextGraphQLObjectTypeFields = {|\n addDataGeneratorForField: (\n fieldName: string,\n fn: DataGeneratorFunction\n ) => void,\n recurseDataGeneratorsForField: (fieldName: string) => void, // @deprecated - DO NOT USE!\n Self: GraphQLNamedType,\n GraphQLObjectType: GraphQLObjectTypeConfig<*, *>,\n fieldWithHooks: FieldWithHooksFunction,\n|};\n\ntype SupportedHookTypes = {} | Build | Array<GraphQLInterfaceType>;\n\nexport type Hook<\n Type: SupportedHookTypes,\n BuildExtensions: *,\n ContextExtensions: *\n> = {\n (\n input: Type,\n build: { ...Build, ...BuildExtensions },\n context: { ...Context, ...ContextExtensions }\n ): Type,\n displayName?: string,\n provides?: Array<string>,\n before?: Array<string>,\n after?: Array<string>,\n};\n\nexport type WatchUnwatch = (triggerChange: TriggerChangeType) => void;\n\nexport type SchemaListener = (newSchema: GraphQLSchema) => void;\n\nclass SchemaBuilder extends EventEmitter {\n options: Options;\n watchers: Array<WatchUnwatch>;\n unwatchers: Array<WatchUnwatch>;\n triggerChange: ?TriggerChangeType;\n depth: number;\n hooks: {\n [string]: Array<Hook<*, *, *>>,\n };\n\n _currentPluginName: ?string;\n _generatedSchema: ?GraphQLSchema;\n _explicitSchemaListener: ?SchemaListener;\n _busy: boolean;\n _watching: boolean;\n\n constructor(options: Options) {\n super();\n\n this.options = options;\n if (!options) {\n throw new Error(\"Please pass options to SchemaBuilder\");\n }\n\n this._busy = false;\n this._watching = false;\n\n this.watchers = [];\n this.unwatchers = [];\n\n // Because hooks can nest, this keeps track of how deep we are.\n this.depth = -1;\n\n this.hooks = {\n // The build object represents the current schema build and is passed to\n // all hooks, hook the 'build' event to extend this object:\n build: [],\n\n // Inflection is used for naming resulting types/fields/args/etc - it's\n // hookable so that other plugins may extend it or override it\n inflection: [],\n\n // 'build' phase should not generate any GraphQL objects (because the\n // build object isn't finalised yet so it risks weirdness occurring); so\n // if you need to set up any global types you can do so here.\n init: [],\n\n // 'finalize' phase is called once the schema is built; typically you\n // shouldn't use this, but it's useful for interfacing with external\n // libraries that mutate an already constructed schema.\n finalize: [],\n\n // Add 'query', 'mutation' or 'subscription' types in this hook:\n GraphQLSchema: [],\n\n // When creating a GraphQLObjectType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLObjectType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLObjectType:interfaces' to add additional interfaces to this object type\n // - 'GraphQLObjectType:fields' to add additional fields to this object type (is\n // ran asynchronously and gets a reference to the final GraphQL Object as\n // `Self` in the context)\n // - 'GraphQLObjectType:fields:field' to customise an individual field from above\n // - 'GraphQLObjectType:fields:field:args' to customize the arguments to a field\n GraphQLObjectType: [],\n \"GraphQLObjectType:interfaces\": [],\n \"GraphQLObjectType:fields\": [],\n \"GraphQLObjectType:fields:field\": [],\n \"GraphQLObjectType:fields:field:args\": [],\n\n // When creating a GraphQLInputObjectType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLInputObjectType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLInputObjectType:fields' to add additional fields to this object type (is\n // ran asynchronously and gets a reference to the final GraphQL Object as\n // `Self` in the context)\n // - 'GraphQLInputObjectType:fields:field' to customise an individual field from above\n GraphQLInputObjectType: [],\n \"GraphQLInputObjectType:fields\": [],\n \"GraphQLInputObjectType:fields:field\": [],\n\n // When creating a GraphQLEnumType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLEnumType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLEnumType:values' to add additional values\n // - 'GraphQLEnumType:values:value' to change an individual value\n GraphQLEnumType: [],\n \"GraphQLEnumType:values\": [],\n \"GraphQLEnumType:values:value\": [],\n\n // When creating a GraphQLUnionType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLUnionType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLUnionType:types' to add additional types to this union\n GraphQLUnionType: [],\n \"GraphQLUnionType:types\": [],\n };\n }\n\n _setPluginName(name: ?string) {\n this._currentPluginName = name;\n }\n\n /*\n * Every hook `fn` takes three arguments:\n * - obj - the object currently being inspected\n * - build - the current build object (which contains a number of utilities and the context of the build)\n * - context - information specific to the current invocation of the hook\n *\n * The function must either return a replacement object for `obj` or `obj` itself\n */\n hook<T: *>(\n hookName: string,\n fn: Hook<T, *, *>,\n provides?: Array<string>,\n before?: Array<string>,\n after?: Array<string>\n ) {\n if (!this.hooks[hookName]) {\n throw new Error(`Sorry, '${hookName}' is not a supported hook`);\n }\n if (this._currentPluginName) {\n fn.displayName = `${this._currentPluginName}/${hookName}/${\n (provides && provides.length && provides.join(\"+\")) ||\n fn.displayName ||\n fn.name ||\n \"unnamed\"\n }`;\n }\n if (provides) {\n if (!fn.displayName && provides.length) {\n fn.displayName = `unknown/${hookName}/${provides[0]}`;\n }\n fn.provides = provides;\n }\n if (before) {\n fn.before = before;\n }\n if (after) {\n fn.after = after;\n }\n if (!fn.provides && !fn.before && !fn.after) {\n // No explicit dependencies - add to the end\n this.hooks[hookName].push(fn);\n } else {\n // We need to figure out where it can go, respecting all the dependencies.\n // TODO: I think there are situations in which this algorithm may result in unnecessary conflict errors; we should take a more iterative approach or find a better algorithm\n const relevantHooks = this.hooks[hookName];\n let minIndex = 0;\n let minReason = null;\n let maxIndex = relevantHooks.length;\n let maxReason = null;\n const { provides: newProvides, before: newBefore, after: newAfter } = fn;\n const describe = (hook, index) => {\n if (!hook) {\n return \"-\";\n }\n return `${hook.displayName || hook.name || \"anonymous\"} (${\n index ? `index: ${index}, ` : \"\"\n }provides: ${hook.provides ? hook.provides.join(\",\") : \"-\"}, before: ${\n hook.before ? hook.before.join(\",\") : \"-\"\n }, after: ${hook.after ? hook.after.join(\",\") : \"-\"})`;\n };\n const check = () => {\n if (minIndex > maxIndex) {\n throw new Error(\n `Cannot resolve plugin order - ${describe(\n fn\n )} cannot be before ${describe(\n maxReason,\n maxIndex\n )} and after ${describe(\n minReason,\n minIndex\n )} - please report this issue`\n );\n }\n };\n const setMin = (newMin, reason) => {\n if (newMin > minIndex) {\n minIndex = newMin;\n minReason = reason;\n check();\n }\n };\n const setMax = (newMax, reason) => {\n if (newMax < maxIndex) {\n maxIndex = newMax;\n maxReason = reason;\n check();\n }\n };\n relevantHooks.forEach((oldHook, idx) => {\n const {\n provides: oldProvides,\n before: oldBefore,\n after: oldAfter,\n } = oldHook;\n if (newProvides) {\n if (oldBefore && oldBefore.some(dep => newProvides.includes(dep))) {\n // Old says it has to come before new\n setMin(idx + 1, oldHook);\n }\n if (oldAfter && oldAfter.some(dep => newProvides.includes(dep))) {\n // Old says it has to be after new\n setMax(idx, oldHook);\n }\n }\n if (oldProvides) {\n if (newBefore && newBefore.some(dep => oldProvides.includes(dep))) {\n // New says it has to come before old\n setMax(idx, oldHook);\n }\n if (newAfter && newAfter.some(dep => oldProvides.includes(dep))) {\n // New says it has to be after old\n setMin(idx + 1, oldHook);\n }\n }\n });\n\n // We've already validated everything, so we can now insert the record.\n this.hooks[hookName].splice(maxIndex, 0, fn);\n }\n }\n\n applyHooks<T: *, Context>(\n build: { ...Build },\n hookName: string,\n input: T,\n context: Context,\n debugStr: string = \"\"\n ): T {\n if (!input) {\n throw new Error(\"applyHooks was called with falsy input\");\n }\n this.depth++;\n try {\n debug(`${INDENT.repeat(this.depth)}[${hookName}${debugStr}]: Running...`);\n\n const hooks: Array<Hook<T, *, *>> = this.hooks[hookName];\n if (!hooks) {\n throw new Error(`Sorry, '${hookName}' is not a registered hook`);\n }\n\n let newObj = input;\n for (const hook: Hook<T, *, *> of hooks) {\n this.depth++;\n try {\n const hookDisplayName = hook.displayName || hook.name || \"anonymous\";\n debug(\n `${INDENT.repeat(\n this.depth\n )}[${hookName}${debugStr}]: Executing '${hookDisplayName}'`\n );\n\n const previousHookName = build.status.currentHookName;\n const previousHookEvent = build.status.currentHookEvent;\n build.status.currentHookName = hookDisplayName;\n build.status.currentHookEvent = hookName;\n const oldObj = newObj;\n newObj = hook(newObj, build, context);\n if (hookName === \"build\") {\n /*\n * Unlike all the other hooks, the `build` hook must always use the\n * same `build` object - never returning a new object for fear of\n * causing issues to other build hooks that reference the old\n * object and don't get the new additions.\n */\n if (newObj !== oldObj) {\n // TODO:v5: forbid this\n // eslint-disable-next-line no-console\n console.warn(\n `Build hook '${hookDisplayName}' returned a new object; please use 'return build.extend(build, {...})' instead.`\n );\n // Copy everything from newObj back to oldObj\n Object.assign(oldObj, newObj);\n // Go back to the old objectect\n newObj = oldObj;\n }\n }\n build.status.currentHookName = previousHookName;\n build.status.currentHookEvent = previousHookEvent;\n\n if (!newObj) {\n throw new Error(\n `Hook '${\n hook.displayName || hook.name || \"anonymous\"\n }' for '${hookName}' returned falsy value '${newObj}'`\n );\n }\n debug(\n `${INDENT.repeat(\n this.depth\n )}[${hookName}${debugStr}]: '${hookDisplayName}' complete`\n );\n } finally {\n this.depth--;\n }\n }\n\n debug(`${INDENT.repeat(this.depth)}[${hookName}${debugStr}]: Complete`);\n\n return newObj;\n } finally {\n this.depth--;\n }\n }\n\n registerWatcher(listen: WatchUnwatch, unlisten: WatchUnwatch) {\n if (!listen || !unlisten) {\n throw new Error(\"You must provide both a listener and an unlistener\");\n }\n this.watchers.push(listen);\n this.unwatchers.push(unlisten);\n }\n\n createBuild(): { ...Build } {\n const initialBuild = makeNewBuild(this);\n // Inflection needs to come first, in case 'build' hooks depend on it\n initialBuild.inflection = this.applyHooks(\n initialBuild,\n \"inflection\",\n initialBuild.inflection,\n {\n scope: {},\n }\n );\n const build = this.applyHooks(initialBuild, \"build\", initialBuild, {\n scope: {},\n });\n // Bind all functions so they can be dereferenced\n bindAll(\n build,\n Object.keys(build).filter(key => typeof build[key] === \"function\")\n );\n Object.freeze(build);\n this.applyHooks(build, \"init\", {}, { scope: {} });\n return build;\n }\n\n buildSchema(): GraphQLSchema {\n if (!this._generatedSchema) {\n const build = this.createBuild();\n const schema = build.newWithHooks(\n GraphQLSchema,\n {\n directives: [...build.graphql.specifiedDirectives],\n },\n {\n __origin: `GraphQL built-in`,\n isSchema: true,\n }\n );\n this._generatedSchema = this.applyHooks(\n build,\n \"finalize\",\n schema,\n {},\n \"Finalising GraphQL schema\"\n );\n }\n if (!this._generatedSchema) {\n throw new Error(\"Schema generation failed\");\n }\n return this._generatedSchema;\n }\n\n async watchSchema(listener?: SchemaListener) {\n if (this._busy) {\n throw new Error(\"An operation is in progress\");\n }\n if (this._watching) {\n throw new Error(\n \"We're already watching this schema! Use `builder.on('schema', callback)` instead.\"\n );\n }\n try {\n this._busy = true;\n this._explicitSchemaListener = listener;\n\n // We want to ignore `triggerChange` calls that occur whilst we're setting\n // up the listeners to prevent an unnecessary double schema build.\n let ignoreChangeTriggers = true;\n\n this.triggerChange = () => {\n if (ignoreChangeTriggers) {\n return;\n }\n this._generatedSchema = null;\n // XXX: optionally debounce\n try {\n const schema = this.buildSchema();\n this.emit(\"schema\", schema);\n } catch (e) {\n // Build errors introduced while watching are ignored because it's\n // primarily used in development.\n // eslint-disable-next-line no-console\n console.error(\n \"⚠️⚠️⚠️ An error occured when building the schema on watch:\"\n );\n // eslint-disable-next-line no-console\n console.error(e);\n }\n };\n try {\n this._watching = true;\n for (const fn of this.watchers) {\n await fn(this.triggerChange);\n }\n\n // Now we're about to build the first schema, any further\n // `triggerChange` calls should be honoured.\n ignoreChangeTriggers = false;\n\n if (listener) {\n this.on(\"schema\", listener);\n }\n this.emit(\"schema\", this.buildSchema());\n } catch (e) {\n try {\n this._busy = false;\n // Abort abort!\n await this.unwatchSchema();\n } catch (e2) {\n console.error(\n `Error when unwatching schema after error during schema build: ${e}`\n );\n }\n throw e;\n }\n } finally {\n this._busy = false;\n }\n }\n\n async unwatchSchema() {\n if (this._busy) {\n throw new Error(\"An operation is in progress\");\n }\n if (!this._watching) {\n throw new Error(\"We're not watching this schema!\");\n }\n this._busy = true;\n try {\n const listener = this._explicitSchemaListener;\n this._explicitSchemaListener = null;\n if (listener) {\n this.removeListener(\"schema\", listener);\n }\n if (this.triggerChange) {\n for (const fn of this.unwatchers) {\n await fn(this.triggerChange);\n }\n }\n this.triggerChange = null;\n this._watching = false;\n } finally {\n this._busy = false;\n }\n }\n}\n\nexport default SchemaBuilder;\n"],"file":"SchemaBuilder.js"}
|
|
1
|
+
{"version":3,"sources":["../src/SchemaBuilder.js"],"names":["GraphQLSchema","graphql","debug","INDENT","SchemaBuilder","EventEmitter","constructor","options","Error","_busy","_watching","watchers","unwatchers","depth","hooks","build","inflection","init","finalize","GraphQLObjectType","GraphQLInputObjectType","GraphQLEnumType","GraphQLUnionType","GraphQLInterfaceType","_setPluginName","name","_currentPluginName","hook","hookName","fn","provides","before","after","displayName","length","join","push","relevantHooks","minIndex","minReason","maxIndex","maxReason","newProvides","newBefore","newAfter","describe","index","check","setMin","newMin","reason","setMax","newMax","forEach","oldHook","idx","oldProvides","oldBefore","oldAfter","some","dep","includes","splice","applyHooks","input","context","debugStr","repeat","newObj","hookDisplayName","previousHookName","status","currentHookName","previousHookEvent","currentHookEvent","oldObj","console","warn","Object","assign","registerWatcher","listen","unlisten","createBuild","initialBuild","scope","keys","filter","key","freeze","buildSchema","_generatedSchema","schema","newWithHooks","directives","specifiedDirectives","__origin","isSchema","hookedSchema","errors","validateSchema","map","e","message","replace","watchSchema","listener","_explicitSchemaListener","ignoreChangeTriggers","triggerChange","emit","error","on","unwatchSchema","e2","removeListener"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAOA;;;;;;;;AAWA,MAAM;AAAEA,EAAAA;AAAF,IAAoBC,OAA1B;AAEA,MAAMC,KAAK,GAAG,oBAAa,kBAAb,CAAd;AAEA,MAAMC,MAAM,GAAG,IAAf;;AA+GA,MAAMC,aAAN,SAA4BC,eAA5B,CAAyC;AAgBvCC,EAAAA,WAAW,CAACC,OAAD,EAAmB;AAC5B;AAEA,SAAKA,OAAL,GAAeA,OAAf;;AACA,QAAI,CAACA,OAAL,EAAc;AACZ,YAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;AACD;;AAED,SAAKC,KAAL,GAAa,KAAb;AACA,SAAKC,SAAL,GAAiB,KAAjB;AAEA,SAAKC,QAAL,GAAgB,EAAhB;AACA,SAAKC,UAAL,GAAkB,EAAlB,CAZ4B,CAc5B;;AACA,SAAKC,KAAL,GAAa,CAAC,CAAd;AAEA,SAAKC,KAAL,GAAa;AACX;AACA;AACAC,MAAAA,KAAK,EAAE,EAHI;AAKX;AACA;AACAC,MAAAA,UAAU,EAAE,EAPD;AASX;AACA;AACA;AACAC,MAAAA,IAAI,EA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eAAKM,EAAL,CAAQ,QAAR,EAAkBN,QAAlB;AACD;;AACD,aAAKI,IAAL,CAAU,QAAV,EAAoB,KAAKpB,WAAL,EAApB;AACD,OAdD,CAcE,OAAOY,CAAP,EAAU;AACV,YAAI;AACF,eAAK7F,KAAL,GAAa,KAAb,CADE,CAEF;;AACA,gBAAM,KAAKwG,aAAL,EAAN;AACD,SAJD,CAIE,OAAOC,EAAP,EAAW;AACXtC,UAAAA,OAAO,CAACmC,KAAR,CACG,iEAAgET,CAAE,EADrE;AAGD;;AACD,cAAMA,CAAN;AACD;AACF,KAtDD,SAsDU;AACR,WAAK7F,KAAL,GAAa,KAAb;AACD;AACF;;AAED,QAAMwG,aAAN,GAAsB;AACpB,QAAI,KAAKxG,KAAT,EAAgB;AACd,YAAM,IAAID,KAAJ,CAAU,6BAAV,CAAN;AACD;;AACD,QAAI,CAAC,KAAKE,SAAV,EAAqB;AACnB,YAAM,IAAIF,KAAJ,CAAU,iCAAV,CAAN;AACD;;AACD,SAAKC,KAAL,GAAa,IAAb;;AACA,QAAI;AACF,YAAMiG,QAAQ,GAAG,KAAKC,uBAAtB;AACA,WAAKA,uBAAL,GAA+B,IAA/B;;AACA,UAAID,QAAJ,EAAc;AACZ,aAAKS,cAAL,CAAoB,QAApB,EAA8BT,QAA9B;AACD;;AACD,UAAI,KAAKG,aAAT,EAAwB;AACtB,aAAK,MAAMhF,EAAX,IAAiB,KAAKjB,UAAtB,EAAkC;AAChC,gBAAMiB,EAAE,CAAC,KAAKgF,aAAN,CAAR;AACD;AACF;;AACD,WAAKA,aAAL,GAAqB,IAArB;AACA,WAAKnG,SAAL,GAAiB,KAAjB;AACD,KAbD,SAaU;AACR,WAAKD,KAAL,GAAa,KAAb;AACD;AACF;;AAhesC;;eAme1BL,a","sourcesContent":["// @flow\nimport debugFactory from \"debug\";\nimport makeNewBuild from \"./makeNewBuild\";\nimport { bindAll } from \"./utils\";\nimport * as graphql from \"graphql\";\nimport type {\n GraphQLType,\n GraphQLNamedType,\n GraphQLInterfaceType,\n GraphQLObjectTypeConfig,\n} from \"graphql\";\nimport EventEmitter from \"events\";\n// TODO: when we move to TypeScript, change this to:\n// import { EventEmitter } from \"events\";\nimport type {\n simplifyParsedResolveInfoFragmentWithType,\n parseResolveInfo,\n} from \"graphql-parse-resolve-info\";\nimport type { GraphQLResolveInfo } from \"graphql/type/definition\";\nimport type resolveNode from \"./resolveNode\";\n\nimport type { FieldWithHooksFunction } from \"./makeNewBuild\";\nconst { GraphQLSchema } = graphql;\n\nconst debug = debugFactory(\"graphile-builder\");\n\nconst INDENT = \" \";\n\nexport type Options = {\n [string]: mixed,\n};\n\nexport type Plugin = (\n builder: SchemaBuilder,\n options: Options\n) => Promise<void> | void;\n\ntype TriggerChangeType = () => void;\n\nexport type DataForType = {\n [string]: Array<mixed>,\n};\n\nexport type Build = {|\n graphileBuildVersion: string,\n graphql: *,\n parseResolveInfo: parseResolveInfo,\n simplifyParsedResolveInfoFragmentWithType: simplifyParsedResolveInfoFragmentWithType,\n // DEPRECATED: getAliasFromResolveInfo: (resolveInfo: GraphQLResolveInfo) => string,\n getSafeAliasFromResolveInfo: (resolveInfo: GraphQLResolveInfo) => string,\n getSafeAliasFromAlias: (alias: string) => string,\n resolveAlias(\n data: {},\n _args: mixed,\n _context: mixed,\n resolveInfo: GraphQLResolveInfo\n ): string,\n addType(type: GraphQLNamedType, origin?: ?string): void,\n getTypeByName(typeName: string): ?GraphQLType,\n extend<Obj1: *, Obj2: *>(base: Obj1, extra: Obj2, hint?: string): Obj1 & Obj2,\n newWithHooks<T: GraphQLNamedType | GraphQLSchema, ConfigType: *>(\n Class<T>,\n spec: ConfigType,\n scope: Scope,\n performNonEmptyFieldsCheck?: boolean\n ): ?T,\n fieldDataGeneratorsByType: Map<*, *>, // @deprecated - use fieldDataGeneratorsByFieldNameByType instead\n fieldDataGeneratorsByFieldNameByType: Map<*, *>,\n fieldArgDataGeneratorsByFieldNameByType: Map<*, *>,\n inflection: {\n // eslint-disable-next-line flowtype/no-weak-types\n [string]: (...args: Array<any>) => string,\n },\n wrapDescription: (\n description: string,\n position: \"root\" | \"type\" | \"field\" | \"arg\"\n ) => string,\n swallowError: (e: Error) => void,\n // resolveNode: EXPERIMENTAL, API might change!\n resolveNode: resolveNode,\n status: {\n currentHookName: ?string,\n currentHookEvent: ?string,\n },\n scopeByType: Map<GraphQLType, Scope>,\n|};\n\nexport type BuildExtensionQuery = {|\n $$isQuery: Symbol,\n|};\n\nexport type Scope = {\n __origin: ?string,\n [string]: mixed,\n};\n\nexport type Context = {|\n scope: Scope,\n type: string,\n [string]: mixed,\n|};\n\ntype DataGeneratorFunction = () => {};\n\nexport type ContextGraphQLObjectTypeFields = {|\n addDataGeneratorForField: (\n fieldName: string,\n fn: DataGeneratorFunction\n ) => void,\n recurseDataGeneratorsForField: (fieldName: string) => void, // @deprecated - DO NOT USE!\n Self: GraphQLNamedType,\n GraphQLObjectType: GraphQLObjectTypeConfig<*, *>,\n fieldWithHooks: FieldWithHooksFunction,\n|};\n\ntype SupportedHookTypes = {} | Build | Array<GraphQLInterfaceType>;\n\nexport type Hook<\n Type: SupportedHookTypes,\n BuildExtensions: *,\n ContextExtensions: *\n> = {\n (\n input: Type,\n build: { ...Build, ...BuildExtensions },\n context: { ...Context, ...ContextExtensions }\n ): Type,\n displayName?: string,\n provides?: Array<string>,\n before?: Array<string>,\n after?: Array<string>,\n};\n\nexport type WatchUnwatch = (triggerChange: TriggerChangeType) => void;\n\nexport type SchemaListener = (newSchema: GraphQLSchema) => void;\n\nclass SchemaBuilder extends EventEmitter {\n options: Options;\n watchers: Array<WatchUnwatch>;\n unwatchers: Array<WatchUnwatch>;\n triggerChange: ?TriggerChangeType;\n depth: number;\n hooks: {\n [string]: Array<Hook<*, *, *>>,\n };\n\n _currentPluginName: ?string;\n _generatedSchema: ?GraphQLSchema;\n _explicitSchemaListener: ?SchemaListener;\n _busy: boolean;\n _watching: boolean;\n\n constructor(options: Options) {\n super();\n\n this.options = options;\n if (!options) {\n throw new Error(\"Please pass options to SchemaBuilder\");\n }\n\n this._busy = false;\n this._watching = false;\n\n this.watchers = [];\n this.unwatchers = [];\n\n // Because hooks can nest, this keeps track of how deep we are.\n this.depth = -1;\n\n this.hooks = {\n // The build object represents the current schema build and is passed to\n // all hooks, hook the 'build' event to extend this object:\n build: [],\n\n // Inflection is used for naming resulting types/fields/args/etc - it's\n // hookable so that other plugins may extend it or override it\n inflection: [],\n\n // 'build' phase should not generate any GraphQL objects (because the\n // build object isn't finalised yet so it risks weirdness occurring); so\n // if you need to set up any global types you can do so here.\n init: [],\n\n // 'finalize' phase is called once the schema is built; typically you\n // shouldn't use this, but it's useful for interfacing with external\n // libraries that mutate an already constructed schema.\n finalize: [],\n\n // Add 'query', 'mutation' or 'subscription' types in this hook:\n GraphQLSchema: [],\n\n // When creating a GraphQLObjectType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLObjectType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLObjectType:interfaces' to add additional interfaces to this object type\n // - 'GraphQLObjectType:fields' to add additional fields to this object type (is\n // ran asynchronously and gets a reference to the final GraphQL Object as\n // `Self` in the context)\n // - 'GraphQLObjectType:fields:field' to customise an individual field from above\n // - 'GraphQLObjectType:fields:field:args' to customize the arguments to a field\n GraphQLObjectType: [],\n \"GraphQLObjectType:interfaces\": [],\n \"GraphQLObjectType:fields\": [],\n \"GraphQLObjectType:fields:field\": [],\n \"GraphQLObjectType:fields:field:args\": [],\n\n // When creating a GraphQLInputObjectType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLInputObjectType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLInputObjectType:fields' to add additional fields to this object type (is\n // ran asynchronously and gets a reference to the final GraphQL Object as\n // `Self` in the context)\n // - 'GraphQLInputObjectType:fields:field' to customise an individual field from above\n GraphQLInputObjectType: [],\n \"GraphQLInputObjectType:fields\": [],\n \"GraphQLInputObjectType:fields:field\": [],\n\n // When creating a GraphQLEnumType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLEnumType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLEnumType:values' to add additional values\n // - 'GraphQLEnumType:values:value' to change an individual value\n GraphQLEnumType: [],\n \"GraphQLEnumType:values\": [],\n \"GraphQLEnumType:values:value\": [],\n\n // When creating a GraphQLUnionType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLUnionType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLUnionType:types' to add additional types to this union\n GraphQLUnionType: [],\n \"GraphQLUnionType:types\": [],\n\n // When creating a GraphQLInterfaceType via `newWithHooks`, we'll\n // execute, the following hooks:\n // - 'GraphQLInterfaceType' to add any root-level attributes, e.g. add a description\n // - 'GraphQLInterfaceType:fields' to add additional fields to this interface type (is\n // ran asynchronously and gets a reference to the final GraphQL Interface as\n // `Self` in the context)\n // - 'GraphQLInterfaceType:fields:field' to customise an individual field from above\n // - 'GraphQLInterfaceType:fields:field:args' to customize the arguments to a field\n GraphQLInterfaceType: [],\n \"GraphQLInterfaceType:fields\": [],\n \"GraphQLInterfaceType:fields:field\": [],\n \"GraphQLInterfaceType:fields:field:args\": [],\n };\n }\n\n _setPluginName(name: ?string) {\n this._currentPluginName = name;\n }\n\n /*\n * Every hook `fn` takes three arguments:\n * - obj - the object currently being inspected\n * - build - the current build object (which contains a number of utilities and the context of the build)\n * - context - information specific to the current invocation of the hook\n *\n * The function must either return a replacement object for `obj` or `obj` itself\n */\n hook<T: *>(\n hookName: string,\n fn: Hook<T, *, *>,\n provides?: Array<string>,\n before?: Array<string>,\n after?: Array<string>\n ) {\n if (!this.hooks[hookName]) {\n throw new Error(`Sorry, '${hookName}' is not a supported hook`);\n }\n if (this._currentPluginName) {\n fn.displayName = `${this._currentPluginName}/${hookName}/${\n (provides && provides.length && provides.join(\"+\")) ||\n fn.displayName ||\n fn.name ||\n \"unnamed\"\n }`;\n }\n if (provides) {\n if (!fn.displayName && provides.length) {\n fn.displayName = `unknown/${hookName}/${provides[0]}`;\n }\n fn.provides = provides;\n }\n if (before) {\n fn.before = before;\n }\n if (after) {\n fn.after = after;\n }\n if (!fn.provides && !fn.before && !fn.after) {\n // No explicit dependencies - add to the end\n this.hooks[hookName].push(fn);\n } else {\n // We need to figure out where it can go, respecting all the dependencies.\n // TODO: I think there are situations in which this algorithm may result in unnecessary conflict errors; we should take a more iterative approach or find a better algorithm\n const relevantHooks = this.hooks[hookName];\n let minIndex = 0;\n let minReason = null;\n let maxIndex = relevantHooks.length;\n let maxReason = null;\n const { provides: newProvides, before: newBefore, after: newAfter } = fn;\n const describe = (hook, index) => {\n if (!hook) {\n return \"-\";\n }\n return `${hook.displayName || hook.name || \"anonymous\"} (${\n index ? `index: ${index}, ` : \"\"\n }provides: ${hook.provides ? hook.provides.join(\",\") : \"-\"}, before: ${\n hook.before ? hook.before.join(\",\") : \"-\"\n }, after: ${hook.after ? hook.after.join(\",\") : \"-\"})`;\n };\n const check = () => {\n if (minIndex > maxIndex) {\n throw new Error(\n `Cannot resolve plugin order - ${describe(\n fn\n )} cannot be before ${describe(\n maxReason,\n maxIndex\n )} and after ${describe(\n minReason,\n minIndex\n )} - please report this issue`\n );\n }\n };\n const setMin = (newMin, reason) => {\n if (newMin > minIndex) {\n minIndex = newMin;\n minReason = reason;\n check();\n }\n };\n const setMax = (newMax, reason) => {\n if (newMax < maxIndex) {\n maxIndex = newMax;\n maxReason = reason;\n check();\n }\n };\n relevantHooks.forEach((oldHook, idx) => {\n const {\n provides: oldProvides,\n before: oldBefore,\n after: oldAfter,\n } = oldHook;\n if (newProvides) {\n if (oldBefore && oldBefore.some(dep => newProvides.includes(dep))) {\n // Old says it has to come before new\n setMin(idx + 1, oldHook);\n }\n if (oldAfter && oldAfter.some(dep => newProvides.includes(dep))) {\n // Old says it has to be after new\n setMax(idx, oldHook);\n }\n }\n if (oldProvides) {\n if (newBefore && newBefore.some(dep => oldProvides.includes(dep))) {\n // New says it has to come before old\n setMax(idx, oldHook);\n }\n if (newAfter && newAfter.some(dep => oldProvides.includes(dep))) {\n // New says it has to be after old\n setMin(idx + 1, oldHook);\n }\n }\n });\n\n // We've already validated everything, so we can now insert the record.\n this.hooks[hookName].splice(maxIndex, 0, fn);\n }\n }\n\n applyHooks<T: *, Context>(\n build: { ...Build },\n hookName: string,\n input: T,\n context: Context,\n debugStr: string = \"\"\n ): T {\n if (!input) {\n throw new Error(\"applyHooks was called with falsy input\");\n }\n this.depth++;\n try {\n debug(`${INDENT.repeat(this.depth)}[${hookName}${debugStr}]: Running...`);\n\n const hooks: Array<Hook<T, *, *>> = this.hooks[hookName];\n if (!hooks) {\n throw new Error(`Sorry, '${hookName}' is not a registered hook`);\n }\n\n let newObj = input;\n for (const hook: Hook<T, *, *> of hooks) {\n this.depth++;\n try {\n const hookDisplayName = hook.displayName || hook.name || \"anonymous\";\n debug(\n `${INDENT.repeat(\n this.depth\n )}[${hookName}${debugStr}]: Executing '${hookDisplayName}'`\n );\n\n const previousHookName = build.status.currentHookName;\n const previousHookEvent = build.status.currentHookEvent;\n build.status.currentHookName = hookDisplayName;\n build.status.currentHookEvent = hookName;\n const oldObj = newObj;\n newObj = hook(newObj, build, context);\n if (hookName === \"build\") {\n /*\n * Unlike all the other hooks, the `build` hook must always use the\n * same `build` object - never returning a new object for fear of\n * causing issues to other build hooks that reference the old\n * object and don't get the new additions.\n */\n if (newObj !== oldObj) {\n // TODO:v5: forbid this\n // eslint-disable-next-line no-console\n console.warn(\n `Build hook '${hookDisplayName}' returned a new object; please use 'return build.extend(build, {...})' instead.`\n );\n // Copy everything from newObj back to oldObj\n Object.assign(oldObj, newObj);\n // Go back to the old objectect\n newObj = oldObj;\n }\n }\n build.status.currentHookName = previousHookName;\n build.status.currentHookEvent = previousHookEvent;\n\n if (!newObj) {\n throw new Error(\n `Hook '${\n hook.displayName || hook.name || \"anonymous\"\n }' for '${hookName}' returned falsy value '${newObj}'`\n );\n }\n debug(\n `${INDENT.repeat(\n this.depth\n )}[${hookName}${debugStr}]: '${hookDisplayName}' complete`\n );\n } finally {\n this.depth--;\n }\n }\n\n debug(`${INDENT.repeat(this.depth)}[${hookName}${debugStr}]: Complete`);\n\n return newObj;\n } finally {\n this.depth--;\n }\n }\n\n registerWatcher(listen: WatchUnwatch, unlisten: WatchUnwatch) {\n if (!listen || !unlisten) {\n throw new Error(\"You must provide both a listener and an unlistener\");\n }\n this.watchers.push(listen);\n this.unwatchers.push(unlisten);\n }\n\n createBuild(): { ...Build } {\n const initialBuild = makeNewBuild(this);\n // Inflection needs to come first, in case 'build' hooks depend on it\n initialBuild.inflection = this.applyHooks(\n initialBuild,\n \"inflection\",\n initialBuild.inflection,\n {\n scope: {},\n }\n );\n const build = this.applyHooks(initialBuild, \"build\", initialBuild, {\n scope: {},\n });\n // Bind all functions so they can be dereferenced\n bindAll(\n build,\n Object.keys(build).filter(key => typeof build[key] === \"function\")\n );\n Object.freeze(build);\n this.applyHooks(build, \"init\", {}, { scope: {} });\n return build;\n }\n\n buildSchema(): GraphQLSchema {\n if (!this._generatedSchema) {\n const build = this.createBuild();\n const schema = build.newWithHooks(\n GraphQLSchema,\n {\n directives: [...build.graphql.specifiedDirectives],\n },\n {\n __origin: `GraphQL built-in`,\n isSchema: true,\n }\n );\n const hookedSchema = this.applyHooks(\n build,\n \"finalize\",\n schema,\n {},\n \"Finalising GraphQL schema\"\n );\n const errors = build.graphql.validateSchema(hookedSchema);\n if (errors && errors.length) {\n throw new Error(\n \"GraphQL schema is invalid:\\n\" +\n errors.map(e => `- ` + e.message.replace(/\\n/g, \"\\n \")).join(\"\\n\")\n );\n }\n this._generatedSchema = hookedSchema;\n }\n if (!this._generatedSchema) {\n throw new Error(\"Schema generation failed\");\n }\n return this._generatedSchema;\n }\n\n async watchSchema(listener?: SchemaListener) {\n if (this._busy) {\n throw new Error(\"An operation is in progress\");\n }\n if (this._watching) {\n throw new Error(\n \"We're already watching this schema! Use `builder.on('schema', callback)` instead.\"\n );\n }\n try {\n this._busy = true;\n this._explicitSchemaListener = listener;\n\n // We want to ignore `triggerChange` calls that occur whilst we're setting\n // up the listeners to prevent an unnecessary double schema build.\n let ignoreChangeTriggers = true;\n\n this.triggerChange = () => {\n if (ignoreChangeTriggers) {\n return;\n }\n this._generatedSchema = null;\n // XXX: optionally debounce\n try {\n const schema = this.buildSchema();\n this.emit(\"schema\", schema);\n } catch (e) {\n // Build errors introduced while watching are ignored because it's\n // primarily used in development.\n // eslint-disable-next-line no-console\n console.error(\n \"⚠️⚠️⚠️ An error occured when building the schema on watch:\"\n );\n // eslint-disable-next-line no-console\n console.error(e);\n }\n };\n try {\n this._watching = true;\n for (const fn of this.watchers) {\n await fn(this.triggerChange);\n }\n\n // Now we're about to build the first schema, any further\n // `triggerChange` calls should be honoured.\n ignoreChangeTriggers = false;\n\n if (listener) {\n this.on(\"schema\", listener);\n }\n this.emit(\"schema\", this.buildSchema());\n } catch (e) {\n try {\n this._busy = false;\n // Abort abort!\n await this.unwatchSchema();\n } catch (e2) {\n console.error(\n `Error when unwatching schema after error during schema build: ${e}`\n );\n }\n throw e;\n }\n } finally {\n this._busy = false;\n }\n }\n\n async unwatchSchema() {\n if (this._busy) {\n throw new Error(\"An operation is in progress\");\n }\n if (!this._watching) {\n throw new Error(\"We're not watching this schema!\");\n }\n this._busy = true;\n try {\n const listener = this._explicitSchemaListener;\n this._explicitSchemaListener = null;\n if (listener) {\n this.removeListener(\"schema\", listener);\n }\n if (this.triggerChange) {\n for (const fn of this.unwatchers) {\n await fn(this.triggerChange);\n }\n }\n this.triggerChange = null;\n this._watching = false;\n } finally {\n this._busy = false;\n }\n }\n}\n\nexport default SchemaBuilder;\n"],"file":"SchemaBuilder.js"}
|
|
@@ -617,6 +617,77 @@ function makeNewBuild(builder) {
|
|
|
617
617
|
return builder.applyHooks(this, "GraphQLUnionType:types", rawTypes, typesContext, `|${getNameFromType(Self)}`);
|
|
618
618
|
}
|
|
619
619
|
};
|
|
620
|
+
} else if (Type === GraphQLInterfaceType) {
|
|
621
|
+
const commonContext = {
|
|
622
|
+
type: "GraphQLInterfaceType",
|
|
623
|
+
scope
|
|
624
|
+
};
|
|
625
|
+
newSpec = builder.applyHooks(this, "GraphQLInterfaceType", newSpec, commonContext, `|${newSpec.name}`);
|
|
626
|
+
const rawSpec = newSpec;
|
|
627
|
+
newSpec = { ...newSpec,
|
|
628
|
+
fields: () => {
|
|
629
|
+
const processedFields = [];
|
|
630
|
+
const fieldsContext = { ...commonContext,
|
|
631
|
+
Self,
|
|
632
|
+
GraphQLInterfaceType: rawSpec,
|
|
633
|
+
fieldWithHooks: (fieldName, spec, fieldScope) => {
|
|
634
|
+
if (!isString(fieldName)) {
|
|
635
|
+
throw new Error("It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is currently necessary.");
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (!fieldScope) {
|
|
639
|
+
throw new Error("All calls to `fieldWithHooks` must specify a `fieldScope` " + "argument that gives additional context about the field so " + "that further plugins may more easily understand the field. " + "Keys within this object should contain the phrase 'field' " + "since they will be merged into the parent objects scope and " + "are not allowed to clash. If you really have no additional " + "information to give, please just pass `{}`.");
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
let newSpec = spec;
|
|
643
|
+
const context = { ...commonContext,
|
|
644
|
+
Self,
|
|
645
|
+
scope: (0, _extend.default)((0, _extend.default)({ ...scope
|
|
646
|
+
}, {
|
|
647
|
+
fieldName
|
|
648
|
+
}, `Within context for GraphQLInterfaceType '${rawSpec.name}'`), fieldScope, `Extending scope for field '${fieldName}' within context for GraphQLInterfaceType '${rawSpec.name}'`)
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
if (typeof newSpec === "function") {
|
|
652
|
+
newSpec = newSpec(context);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
newSpec = builder.applyHooks(this, "GraphQLInterfaceType:fields:field", newSpec, context, `|${getNameFromType(Self)}.fields.${fieldName}`);
|
|
656
|
+
newSpec.args = newSpec.args || {};
|
|
657
|
+
newSpec = { ...newSpec,
|
|
658
|
+
args: builder.applyHooks(this, "GraphQLInterfaceType:fields:field:args", newSpec.args, { ...context,
|
|
659
|
+
field: newSpec,
|
|
660
|
+
returnType: newSpec.type
|
|
661
|
+
}, `|${getNameFromType(Self)}.fields.${fieldName}`)
|
|
662
|
+
};
|
|
663
|
+
const finalSpec = newSpec;
|
|
664
|
+
processedFields.push(finalSpec);
|
|
665
|
+
return finalSpec;
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
let rawFields = rawSpec.fields || {};
|
|
669
|
+
|
|
670
|
+
if (typeof rawFields === "function") {
|
|
671
|
+
rawFields = rawFields(fieldsContext);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
const fieldsSpec = builder.applyHooks(this, "GraphQLInterfaceType:fields", this.extend({}, rawFields, `Default field included in newWithHooks call for '${rawSpec.name}'. ${inScope.__origin || ""}`), fieldsContext, `|${rawSpec.name}`); // Finally, check through all the fields that they've all been processed; any that have not we should do so now.
|
|
675
|
+
|
|
676
|
+
for (const fieldName in fieldsSpec) {
|
|
677
|
+
const fieldSpec = fieldsSpec[fieldName];
|
|
678
|
+
|
|
679
|
+
if (processedFields.indexOf(fieldSpec) < 0) {
|
|
680
|
+
// We've not processed this yet; process it now!
|
|
681
|
+
fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(fieldName, fieldSpec, {
|
|
682
|
+
autoField: true // We don't have any additional information
|
|
683
|
+
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
return fieldsSpec;
|
|
689
|
+
}
|
|
690
|
+
};
|
|
620
691
|
}
|
|
621
692
|
|
|
622
693
|
const finalSpec = newSpec;
|
|
@@ -860,6 +860,126 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
860
860
|
);
|
|
861
861
|
},
|
|
862
862
|
};
|
|
863
|
+
} else if (Type === GraphQLInterfaceType) {
|
|
864
|
+
const commonContext = {
|
|
865
|
+
type: "GraphQLInterfaceType",
|
|
866
|
+
scope,
|
|
867
|
+
};
|
|
868
|
+
newSpec = builder.applyHooks(
|
|
869
|
+
this,
|
|
870
|
+
"GraphQLInterfaceType",
|
|
871
|
+
newSpec,
|
|
872
|
+
commonContext,
|
|
873
|
+
`|${newSpec.name}`
|
|
874
|
+
);
|
|
875
|
+
|
|
876
|
+
const rawSpec = newSpec;
|
|
877
|
+
newSpec = {
|
|
878
|
+
...newSpec,
|
|
879
|
+
fields: () => {
|
|
880
|
+
const processedFields = [];
|
|
881
|
+
const fieldsContext = {
|
|
882
|
+
...commonContext,
|
|
883
|
+
Self,
|
|
884
|
+
GraphQLInterfaceType: rawSpec,
|
|
885
|
+
fieldWithHooks: ((fieldName, spec, fieldScope) => {
|
|
886
|
+
if (!isString(fieldName)) {
|
|
887
|
+
throw new Error(
|
|
888
|
+
"It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is currently necessary."
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
if (!fieldScope) {
|
|
892
|
+
throw new Error(
|
|
893
|
+
"All calls to `fieldWithHooks` must specify a `fieldScope` " +
|
|
894
|
+
"argument that gives additional context about the field so " +
|
|
895
|
+
"that further plugins may more easily understand the field. " +
|
|
896
|
+
"Keys within this object should contain the phrase 'field' " +
|
|
897
|
+
"since they will be merged into the parent objects scope and " +
|
|
898
|
+
"are not allowed to clash. If you really have no additional " +
|
|
899
|
+
"information to give, please just pass `{}`."
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
let newSpec = spec;
|
|
904
|
+
const context = {
|
|
905
|
+
...commonContext,
|
|
906
|
+
Self,
|
|
907
|
+
scope: extend(
|
|
908
|
+
extend(
|
|
909
|
+
{ ...scope },
|
|
910
|
+
{
|
|
911
|
+
fieldName,
|
|
912
|
+
},
|
|
913
|
+
`Within context for GraphQLInterfaceType '${rawSpec.name}'`
|
|
914
|
+
),
|
|
915
|
+
fieldScope,
|
|
916
|
+
`Extending scope for field '${fieldName}' within context for GraphQLInterfaceType '${rawSpec.name}'`
|
|
917
|
+
),
|
|
918
|
+
};
|
|
919
|
+
if (typeof newSpec === "function") {
|
|
920
|
+
newSpec = newSpec(context);
|
|
921
|
+
}
|
|
922
|
+
newSpec = builder.applyHooks(
|
|
923
|
+
this,
|
|
924
|
+
"GraphQLInterfaceType:fields:field",
|
|
925
|
+
newSpec,
|
|
926
|
+
context,
|
|
927
|
+
`|${getNameFromType(Self)}.fields.${fieldName}`
|
|
928
|
+
);
|
|
929
|
+
newSpec.args = newSpec.args || {};
|
|
930
|
+
newSpec = {
|
|
931
|
+
...newSpec,
|
|
932
|
+
args: builder.applyHooks(
|
|
933
|
+
this,
|
|
934
|
+
"GraphQLInterfaceType:fields:field:args",
|
|
935
|
+
newSpec.args,
|
|
936
|
+
{
|
|
937
|
+
...context,
|
|
938
|
+
field: newSpec,
|
|
939
|
+
returnType: newSpec.type,
|
|
940
|
+
},
|
|
941
|
+
`|${getNameFromType(Self)}.fields.${fieldName}`
|
|
942
|
+
),
|
|
943
|
+
};
|
|
944
|
+
const finalSpec = newSpec;
|
|
945
|
+
processedFields.push(finalSpec);
|
|
946
|
+
return finalSpec;
|
|
947
|
+
}: FieldWithHooksFunction),
|
|
948
|
+
};
|
|
949
|
+
let rawFields = rawSpec.fields || {};
|
|
950
|
+
if (typeof rawFields === "function") {
|
|
951
|
+
rawFields = rawFields(fieldsContext);
|
|
952
|
+
}
|
|
953
|
+
const fieldsSpec = builder.applyHooks(
|
|
954
|
+
this,
|
|
955
|
+
"GraphQLInterfaceType:fields",
|
|
956
|
+
this.extend(
|
|
957
|
+
{},
|
|
958
|
+
rawFields,
|
|
959
|
+
`Default field included in newWithHooks call for '${
|
|
960
|
+
rawSpec.name
|
|
961
|
+
}'. ${inScope.__origin || ""}`
|
|
962
|
+
),
|
|
963
|
+
fieldsContext,
|
|
964
|
+
`|${rawSpec.name}`
|
|
965
|
+
);
|
|
966
|
+
// Finally, check through all the fields that they've all been processed; any that have not we should do so now.
|
|
967
|
+
for (const fieldName in fieldsSpec) {
|
|
968
|
+
const fieldSpec = fieldsSpec[fieldName];
|
|
969
|
+
if (processedFields.indexOf(fieldSpec) < 0) {
|
|
970
|
+
// We've not processed this yet; process it now!
|
|
971
|
+
fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(
|
|
972
|
+
fieldName,
|
|
973
|
+
fieldSpec,
|
|
974
|
+
{
|
|
975
|
+
autoField: true, // We don't have any additional information
|
|
976
|
+
}
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return fieldsSpec;
|
|
981
|
+
},
|
|
982
|
+
};
|
|
863
983
|
}
|
|
864
984
|
|
|
865
985
|
const finalSpec: ConfigType = newSpec;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/makeNewBuild.js"],"names":["recurseDataGeneratorsForFieldWarned","isString","str","isDev","indexOf","process","env","NODE_ENV","debug","hashCache","LRU","maxLength","hashFieldAlias","precomputed","get","hash","update","digest","set","getSafeAliasFromAlias","alias","length","startsWith","Error","getSafeAliasFromResolveInfo","resolveInfo","getNameFromType","Type","GraphQLSchema","name","GraphQLInterfaceType","GraphQLObjectType","GraphQLInputObjectType","GraphQLEnumType","GraphQLUnionType","getNamedType","isCompositeType","isAbstractType","graphql","mergeData","data","gen","ReturnType","arg","results","ensureArray","resultIndex","resultCount","result","keys","Object","i","l","k","value","newData","push","knownTypes","knownTypeNames","map","val","Array","isArray","ensureName","_fn","fn","displayName","enabled","console","trace","makeNewBuild","builder","allTypes","Int","GraphQLInt","Float","GraphQLFloat","String","GraphQLString","Boolean","GraphQLBoolean","ID","GraphQLID","allTypesSources","fieldDataGeneratorsByFieldNameByType","Map","fieldArgDataGeneratorsByFieldNameByType","options","graphileBuildVersion","version","versions","require","hasVersion","packageName","range","includePrerelease","packageVersion","semver","satisfies","parseResolveInfo","simplifyParsedResolveInfoFragmentWithType","getAliasFromResolveInfo","resolveAlias","_args","_context","addType","type","origin","newTypeSource","status","currentHookName","oldTypeSource","firstEntityDetails","chalk","magenta","secondEntityDetails","yellow","bold","getTypeByName","typeName","extend","newWithHooks","spec","inScope","performNonEmptyFieldsCheck","scope","warn","fieldDataGeneratorsByFieldName","fieldArgDataGeneratorsByFieldName","newSpec","applyHooks","addDataGeneratorForField","fieldName","Self","recurseDataGeneratorsForField","iKnowWhatIAmDoing","error","parsedResolveInfoFragment","rest","args","fields","StrippedType","argDataGeneratorsForSelfByFieldName","argDataGenerators","genIndex","genCount","local","typeFields","getFields","keyIndex","keyCount","field","gens","commonContext","rawSpec","interfaces","interfacesContext","rawInterfaces","processedFields","fieldsContext","fieldWithHooks","fieldScope","context","addDataGenerator","addArgDataGenerator","getDataFromParsedResolveInfoFragment","dgIndex","dgCount","e","finalSpec","FieldReturnType","returnType","rawFields","fieldsSpec","__origin","fieldSpec","autoField","values","reduce","memo","valueKey","newValue","types","typesContext","rawTypes","_Self","isRootQuery","isProbablyAnEmptyObjectError","message","match","swallowError","scopeByType","fieldDataGeneratorsByType","inflection","pluralize","singularize","singular","upperCamelCase","camelCase","constantCase","builtin","live","coerceToGraphQLName","resultingName","replace","wrapDescription","resolveNode","currentHookEvent","liveCoordinator","LiveCoordinator"],"mappings":";;;;;;;AAEA;;AAOA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AASA;;AACA;;AACA;;AAEA;;;;;;;;AAEA,IAAIA,mCAAmC,GAAG,KAA1C;;AAEA,MAAMC,QAAQ,GAAGC,GAAG,IAAI,OAAOA,GAAP,KAAe,QAAvC;;AACA,MAAMC,KAAK,GAAG,CAAC,MAAD,EAAS,aAAT,EAAwBC,OAAxB,CAAgCC,OAAO,CAACC,GAAR,CAAYC,QAA5C,KAAyD,CAAvE;AACA,MAAMC,KAAK,GAAG,oBAAa,gBAAb,CAAd;AAEA;;;;;;;;;AAQA,MAAMC,SAAS,GAAG,IAAIC,YAAJ,CAAQ;AAAEC,EAAAA,S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,MAAM,EAAE;AACNC,MAAAA,eAAe,EAAE,IADX;AAENiG,MAAAA,gBAAgB,EAAE;AAFZ,KA3tBH;AA+tBLC,IAAAA,eAAe,EAAE,IAAIC,qBAAJ,EA/tBZ;AAguBLlB,IAAAA,WAAW,EAAE,IAAI1G,GAAJ;AAhuBR,GAAP;AAkuBD","sourcesContent":["// @flow\n\nimport * as graphql from \"graphql\";\nimport type {\n GraphQLNamedType,\n GraphQLInputField,\n GraphQLFieldResolver,\n GraphQLType,\n} from \"graphql\";\nimport {\n parseResolveInfo,\n simplifyParsedResolveInfoFragmentWithType,\n getAliasFromResolveInfo as rawGetAliasFromResolveInfo,\n} from \"graphql-parse-resolve-info\";\nimport debugFactory from \"debug\";\nimport type { ResolveTree } from \"graphql-parse-resolve-info\";\nimport pluralize from \"pluralize\";\nimport LRU from \"@graphile/lru\";\nimport semver from \"semver\";\nimport {\n upperCamelCase,\n camelCase,\n constantCase,\n wrapDescription,\n} from \"./utils\";\nimport swallowError from \"./swallowError\";\nimport resolveNode from \"./resolveNode\";\nimport { LiveCoordinator } from \"./Live\";\n\nimport type SchemaBuilder, {\n Build,\n Context,\n Scope,\n DataForType,\n} from \"./SchemaBuilder\";\n\nimport extend, { indent } from \"./extend\";\nimport chalk from \"chalk\";\nimport { createHash } from \"crypto\";\n\nimport { version } from \"../package.json\";\n\nlet recurseDataGeneratorsForFieldWarned = false;\n\nconst isString = str => typeof str === \"string\";\nconst isDev = [\"test\", \"development\"].indexOf(process.env.NODE_ENV) >= 0;\nconst debug = debugFactory(\"graphile-build\");\n\n/*\n * This should be more than enough for normal usage. If you come under a\n * sophisticated attack then the attacker can empty this of useful values (with\n * a lot of work) but because we use SHA1 hashes under the covers the aliases\n * will still be consistent even after the LRU cache is exhausted. And SHA1 can\n * produce half a million hashes per second on my machine, the LRU only gives\n * us a 10x speedup!\n */\nconst hashCache = new LRU({ maxLength: 100000 });\n\n/*\n * This function must never return a string longer than 56 characters.\n *\n * This function must only output alphanumeric and underscore characters.\n *\n * Collisions in SHA1 aren't problematic here (for us; they will be problematic\n * for the user deliberately causing them, but that's their own fault!), so\n * we'll happily take the performance boost over SHA256.\n */\nfunction hashFieldAlias(str) {\n const precomputed = hashCache.get(str);\n if (precomputed) return precomputed;\n const hash = createHash(\"sha1\").update(str).digest(\"hex\");\n hashCache.set(str, hash);\n return hash;\n}\n\n/*\n * This function may be replaced at any time, but all versions of it will\n * always return a representation of `alias` (a valid GraphQL identifier)\n * that:\n *\n * 1. won't conflict with normal GraphQL field names\n * 2. won't be over 60 characters long (allows for systems with alias length limits, such as PG)\n * 3. will give the same value when called multiple times within the same GraphQL query\n * 4. matches the regex /^[@!-_A-Za-z0-9]+$/\n * 5. will not be prefixed with `__` (as that will conflict with other Graphile internals)\n *\n * It does not guarantee that this alias will be human readable!\n */\nfunction getSafeAliasFromAlias(alias) {\n if (alias.length <= 60 && !alias.startsWith(\"@\")) {\n // Use the `@` to prevent conflicting with normal GraphQL field names, but otherwise let it through verbatim.\n return `@${alias}`;\n } else if (alias.length > 1024) {\n throw new Error(\n `GraphQL alias '${alias}' is too long, use shorter aliases (max length 1024).`\n );\n } else {\n return `@@${hashFieldAlias(alias)}`;\n }\n}\n\n/*\n * This provides a \"safe\" version of the alias from ResolveInfo, guaranteed to\n * never be longer than 60 characters. This makes it suitable as a PostgreSQL\n * identifier.\n */\nfunction getSafeAliasFromResolveInfo(resolveInfo) {\n const alias = rawGetAliasFromResolveInfo(resolveInfo);\n return getSafeAliasFromAlias(alias);\n}\n\ntype MetaData = {\n [string]: Array<mixed>,\n};\ntype DataGeneratorFunction = (\n parsedResolveInfoFragment: ResolveTree,\n ReturnType: GraphQLType,\n ...args: Array<mixed>\n) => Array<MetaData>;\n\ntype FieldSpecIsh = {\n type?: GraphQLType,\n args?: {},\n resolve?: GraphQLFieldResolver<*, *>,\n deprecationReason?: string,\n description?: ?string,\n};\n\ntype ContextAndGenerators =\n | Context\n | {\n addDataGenerator: DataGeneratorFunction => void,\n addArgDataGenerator: DataGeneratorFunction => void,\n getDataFromParsedResolveInfoFragment: (\n parsedResolveInfoFragment: ResolveTree,\n Type: GraphQLType\n ) => DataForType,\n };\n\nexport type FieldWithHooksFunction = (\n fieldName: string,\n spec: FieldSpecIsh | (ContextAndGenerators => FieldSpecIsh),\n fieldScope?: {}\n) => {};\n\nexport type InputFieldWithHooksFunction = (\n fieldName: string,\n spec: GraphQLInputField,\n fieldScope?: {}\n) => GraphQLInputField;\n\nfunction getNameFromType(Type: GraphQLNamedType | GraphQLSchema) {\n if (Type instanceof GraphQLSchema) {\n return \"schema\";\n } else {\n return Type.name;\n }\n}\n\nconst {\n GraphQLSchema,\n GraphQLInterfaceType,\n GraphQLObjectType,\n GraphQLInputObjectType,\n GraphQLEnumType,\n GraphQLUnionType,\n getNamedType,\n isCompositeType,\n isAbstractType,\n} = graphql;\n\nconst mergeData = (\n data: MetaData,\n gen: DataGeneratorFunction,\n ReturnType,\n arg\n) => {\n const results: ?Array<MetaData> = ensureArray<MetaData>(\n gen(arg, ReturnType, data)\n );\n if (!results) {\n return;\n }\n for (\n let resultIndex = 0, resultCount = results.length;\n resultIndex < resultCount;\n resultIndex++\n ) {\n const result: MetaData = results[resultIndex];\n const keys = Object.keys(result);\n for (let i = 0, l = keys.length; i < l; i++) {\n const k = keys[i];\n data[k] = data[k] || [];\n const value: mixed = result[k];\n const newData: ?Array<mixed> = ensureArray<mixed>(value);\n if (newData) {\n data[k].push(...newData);\n }\n }\n }\n};\n\nconst knownTypes = [\n GraphQLSchema,\n GraphQLObjectType,\n GraphQLInputObjectType,\n GraphQLEnumType,\n GraphQLUnionType,\n];\nconst knownTypeNames = knownTypes.map(k => k.name);\n\nfunction ensureArray<T>(val: null | T | Array<T>): void | Array<T> {\n if (val == null) {\n return;\n } else if (Array.isArray(val)) {\n // $FlowFixMe\n return (val: Array<T>);\n } else {\n return ([val]: Array<T>);\n }\n}\n\n// eslint-disable-next-line no-unused-vars\nlet ensureName = _fn => {};\nif ([\"development\", \"test\"].indexOf(process.env.NODE_ENV) >= 0) {\n ensureName = fn => {\n // $FlowFixMe: displayName\n if (isDev && !fn.displayName && !fn.name && debug.enabled) {\n // eslint-disable-next-line no-console\n console.trace(\n \"WARNING: you've added a function with no name as an argDataGenerator, doing so may make debugging more challenging\"\n );\n }\n };\n}\n\nexport default function makeNewBuild(builder: SchemaBuilder): { ...Build } {\n const allTypes = {\n Int: graphql.GraphQLInt,\n Float: graphql.GraphQLFloat,\n String: graphql.GraphQLString,\n Boolean: graphql.GraphQLBoolean,\n ID: graphql.GraphQLID,\n };\n const allTypesSources = {\n Int: \"GraphQL Built-in\",\n Float: \"GraphQL Built-in\",\n String: \"GraphQL Built-in\",\n Boolean: \"GraphQL Built-in\",\n ID: \"GraphQL Built-in\",\n };\n\n // Every object type gets fieldData associated with each of its\n // fields.\n\n // When a field is defined, it may add to this field data.\n\n // When something resolves referencing this type, the resolver may\n // request the fieldData, e.g. to perform optimisations.\n\n // fieldData is an object whose keys are the fields on this\n // GraphQLObjectType and whose values are an object (whose keys are\n // arbitrary namespaced keys and whose values are arrays of\n // information of this kind)\n const fieldDataGeneratorsByFieldNameByType = new Map();\n const fieldArgDataGeneratorsByFieldNameByType = new Map();\n\n return {\n options: builder.options,\n graphileBuildVersion: version,\n versions: {\n graphql: require(\"graphql/package.json\").version,\n \"graphile-build\": version,\n },\n hasVersion(\n packageName: string,\n range: string,\n options?: { includePrerelease?: boolean } = { includePrerelease: true }\n ): boolean {\n const packageVersion = this.versions[packageName];\n if (!packageVersion) return false;\n return semver.satisfies(packageVersion, range, options);\n },\n graphql,\n parseResolveInfo,\n simplifyParsedResolveInfoFragmentWithType,\n getSafeAliasFromAlias,\n getAliasFromResolveInfo: getSafeAliasFromResolveInfo, // DEPRECATED: do not use this!\n getSafeAliasFromResolveInfo,\n resolveAlias(data, _args, _context, resolveInfo) {\n const alias = getSafeAliasFromResolveInfo(resolveInfo);\n return data[alias];\n },\n addType(type: GraphQLNamedType, origin?: ?string): void {\n if (!type.name) {\n throw new Error(\n `addType must only be called with named types, try using require('graphql').getNamedType`\n );\n }\n const newTypeSource =\n origin ||\n // 'this' is typically only available after the build is finalized\n (this\n ? `'addType' call during hook '${this.status.currentHookName}'`\n : null);\n if (allTypes[type.name]) {\n if (allTypes[type.name] !== type) {\n const oldTypeSource = allTypesSources[type.name];\n const firstEntityDetails = !oldTypeSource\n ? \"The first type was registered from an unknown origin.\"\n : `The first entity was:\\n\\n${indent(\n chalk.magenta(oldTypeSource)\n )}`;\n const secondEntityDetails = !newTypeSource\n ? \"The second type was registered from an unknown origin.\"\n : `The second entity was:\\n\\n${indent(\n chalk.yellow(newTypeSource)\n )}`;\n throw new Error(\n `A type naming conflict has occurred - two entities have tried to define the same type '${chalk.bold(\n type.name\n )}'.\\n\\n${indent(firstEntityDetails)}\\n\\n${indent(\n secondEntityDetails\n )}`\n );\n }\n } else {\n allTypes[type.name] = type;\n allTypesSources[type.name] = newTypeSource;\n }\n },\n getTypeByName(typeName) {\n return allTypes[typeName];\n },\n extend,\n newWithHooks<T: GraphQLNamedType | GraphQLSchema, ConfigType: *>(\n Type: Class<T>,\n spec: ConfigType,\n inScope: Scope,\n performNonEmptyFieldsCheck = false\n ): ?T {\n const scope = inScope || {};\n if (!inScope) {\n // eslint-disable-next-line no-console\n console.warn(\n `No scope was provided to new ${Type.name}[name=${spec.name}], it's highly recommended that you add a scope so other hooks can easily reference your object - please check usage of 'newWithHooks'. To mute this message, just pass an empty object.`\n );\n }\n if (!Type) {\n throw new Error(\"No type specified!\");\n }\n if (!this.newWithHooks) {\n throw new Error(\n \"Please do not generate the schema during the build building phase, use 'init' instead\"\n );\n }\n const fieldDataGeneratorsByFieldName = {};\n const fieldArgDataGeneratorsByFieldName = {};\n let newSpec = spec;\n if (\n knownTypes.indexOf(Type) === -1 &&\n knownTypeNames.indexOf(Type.name) >= 0\n ) {\n throw new Error(\n `GraphQL conflict for '${Type.name}' detected! Multiple versions of graphql exist in your node_modules?`\n );\n }\n if (Type === GraphQLSchema) {\n newSpec = builder.applyHooks(this, \"GraphQLSchema\", newSpec, {\n type: \"GraphQLSchema\",\n scope,\n });\n } else if (Type === GraphQLObjectType) {\n const addDataGeneratorForField = (\n fieldName,\n fn: DataGeneratorFunction\n ) => {\n // $FlowFixMe: displayName\n fn.displayName =\n // $FlowFixMe: displayName\n fn.displayName ||\n `${getNameFromType(Self)}:${fieldName}[${fn.name || \"anonymous\"}]`;\n fieldDataGeneratorsByFieldName[fieldName] =\n fieldDataGeneratorsByFieldName[fieldName] || [];\n fieldDataGeneratorsByFieldName[fieldName].push(fn);\n };\n const recurseDataGeneratorsForField = (\n fieldName,\n iKnowWhatIAmDoing\n ) => {\n /*\n * Recursing data generators is not safe in general; however there\n * are certain exceptions - for example when you know there are no\n * \"dynamic\" data generator fields - e.g. where the GraphQL alias is\n * not used at all. In PostGraphile the only case of this is the\n * PageInfo object as none of the fields accept arguments, and they\n * do not rely on the GraphQL query alias to store the result.\n */\n if (!iKnowWhatIAmDoing && !recurseDataGeneratorsForFieldWarned) {\n recurseDataGeneratorsForFieldWarned = true;\n // eslint-disable-next-line no-console\n console.error(\n \"Use of `recurseDataGeneratorsForField` is NOT SAFE. e.g. `{n1: node { a: field1 }, n2: node { a: field2 } }` cannot resolve correctly.\"\n );\n }\n const fn = (parsedResolveInfoFragment, ReturnType, ...rest) => {\n const { args } = parsedResolveInfoFragment;\n const { fields } = this.simplifyParsedResolveInfoFragmentWithType(\n parsedResolveInfoFragment,\n ReturnType\n );\n const results = [];\n const StrippedType: GraphQLNamedType = getNamedType(ReturnType);\n const fieldDataGeneratorsByFieldName = fieldDataGeneratorsByFieldNameByType.get(\n StrippedType\n );\n const argDataGeneratorsForSelfByFieldName = fieldArgDataGeneratorsByFieldNameByType.get(\n Self\n );\n if (argDataGeneratorsForSelfByFieldName) {\n const argDataGenerators =\n argDataGeneratorsForSelfByFieldName[fieldName];\n for (\n let genIndex = 0, genCount = argDataGenerators.length;\n genIndex < genCount;\n genIndex++\n ) {\n const gen = argDataGenerators[genIndex];\n const local = ensureArray(gen(args, ReturnType, ...rest));\n if (local) {\n results.push(...local);\n }\n }\n }\n if (\n fieldDataGeneratorsByFieldName &&\n isCompositeType(StrippedType) &&\n !isAbstractType(StrippedType)\n ) {\n const typeFields = StrippedType.getFields();\n const keys = Object.keys(fields);\n for (\n let keyIndex = 0, keyCount = keys.length;\n keyIndex < keyCount;\n keyIndex++\n ) {\n const alias = keys[keyIndex];\n const field = fields[alias];\n // Run generators with `field` as the `parsedResolveInfoFragment`, pushing results to `results`\n const gens = fieldDataGeneratorsByFieldName[field.name];\n if (gens) {\n for (\n let genIndex = 0, genCount = gens.length;\n genIndex < genCount;\n genIndex++\n ) {\n const gen = gens[genIndex];\n const local = ensureArray(\n gen(field, typeFields[field.name].type, ...rest)\n );\n if (local) {\n results.push(...local);\n }\n }\n }\n }\n }\n return results;\n };\n fn.displayName = `recurseDataGeneratorsForField(${getNameFromType(\n Self\n )}:${fieldName})`;\n addDataGeneratorForField(fieldName, fn);\n // get type from field, get\n };\n\n const commonContext = {\n type: \"GraphQLObjectType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLObjectType\",\n newSpec,\n {\n ...commonContext,\n addDataGeneratorForField,\n recurseDataGeneratorsForField,\n },\n `|${newSpec.name}`\n );\n\n const rawSpec = newSpec;\n newSpec = {\n ...newSpec,\n interfaces: () => {\n const interfacesContext = {\n ...commonContext,\n Self,\n GraphQLObjectType: rawSpec,\n };\n let rawInterfaces = rawSpec.interfaces || [];\n if (typeof rawInterfaces === \"function\") {\n rawInterfaces = rawInterfaces(interfacesContext);\n }\n return builder.applyHooks(\n this,\n \"GraphQLObjectType:interfaces\",\n rawInterfaces,\n interfacesContext,\n `|${getNameFromType(Self)}`\n );\n },\n fields: () => {\n const processedFields = [];\n const fieldsContext = {\n ...commonContext,\n addDataGeneratorForField,\n recurseDataGeneratorsForField,\n Self,\n GraphQLObjectType: rawSpec,\n fieldWithHooks: ((fieldName, spec, fieldScope) => {\n if (!isString(fieldName)) {\n throw new Error(\n \"It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is currently necessary.\"\n );\n }\n if (!fieldScope) {\n throw new Error(\n \"All calls to `fieldWithHooks` must specify a `fieldScope` \" +\n \"argument that gives additional context about the field so \" +\n \"that further plugins may more easily understand the field. \" +\n \"Keys within this object should contain the phrase 'field' \" +\n \"since they will be merged into the parent objects scope and \" +\n \"are not allowed to clash. If you really have no additional \" +\n \"information to give, please just pass `{}`.\"\n );\n }\n\n const argDataGenerators = [];\n fieldArgDataGeneratorsByFieldName[\n fieldName\n ] = argDataGenerators;\n\n let newSpec = spec;\n const context = {\n ...commonContext,\n Self,\n addDataGenerator(fn) {\n return addDataGeneratorForField(fieldName, fn);\n },\n addArgDataGenerator(fn) {\n ensureName(fn);\n argDataGenerators.push(fn);\n },\n getDataFromParsedResolveInfoFragment: (\n parsedResolveInfoFragment,\n ReturnType\n ): DataForType => {\n const Type: GraphQLNamedType = getNamedType(ReturnType);\n const data = {};\n\n const {\n fields,\n args,\n } = this.simplifyParsedResolveInfoFragmentWithType(\n parsedResolveInfoFragment,\n ReturnType\n );\n\n // Args -> argDataGenerators\n for (\n let dgIndex = 0, dgCount = argDataGenerators.length;\n dgIndex < dgCount;\n dgIndex++\n ) {\n const gen = argDataGenerators[dgIndex];\n try {\n mergeData(data, gen, ReturnType, args);\n } catch (e) {\n debug(\n \"Failed to execute argDataGenerator '%s' on %s of %s\",\n gen.displayName || gen.name || \"anonymous\",\n fieldName,\n getNameFromType(Self)\n );\n throw e;\n }\n }\n\n // finalSpec.type -> fieldData\n if (!finalSpec) {\n throw new Error(\n \"It's too early to call this! Call from within resolve\"\n );\n }\n const fieldDataGeneratorsByFieldName = fieldDataGeneratorsByFieldNameByType.get(\n Type\n );\n if (\n fieldDataGeneratorsByFieldName &&\n isCompositeType(Type) &&\n !isAbstractType(Type)\n ) {\n const typeFields = Type.getFields();\n const keys = Object.keys(fields);\n for (\n let keyIndex = 0, keyCount = keys.length;\n keyIndex < keyCount;\n keyIndex++\n ) {\n const alias = keys[keyIndex];\n const field = fields[alias];\n const gens = fieldDataGeneratorsByFieldName[field.name];\n if (gens) {\n const FieldReturnType = typeFields[field.name].type;\n for (let i = 0, l = gens.length; i < l; i++) {\n mergeData(data, gens[i], FieldReturnType, field);\n }\n }\n }\n }\n return data;\n },\n scope: extend(\n extend(\n { ...scope },\n {\n fieldName,\n },\n `Within context for GraphQLObjectType '${rawSpec.name}'`\n ),\n fieldScope,\n `Extending scope for field '${fieldName}' within context for GraphQLObjectType '${rawSpec.name}'`\n ),\n };\n if (typeof newSpec === \"function\") {\n newSpec = newSpec(context);\n }\n newSpec = builder.applyHooks(\n this,\n \"GraphQLObjectType:fields:field\",\n newSpec,\n context,\n `|${getNameFromType(Self)}.fields.${fieldName}`\n );\n newSpec.args = newSpec.args || {};\n newSpec = {\n ...newSpec,\n args: builder.applyHooks(\n this,\n \"GraphQLObjectType:fields:field:args\",\n newSpec.args,\n {\n ...context,\n field: newSpec,\n returnType: newSpec.type,\n },\n `|${getNameFromType(Self)}.fields.${fieldName}`\n ),\n };\n const finalSpec = newSpec;\n processedFields.push(finalSpec);\n return finalSpec;\n }: FieldWithHooksFunction),\n };\n let rawFields = rawSpec.fields || {};\n if (typeof rawFields === \"function\") {\n rawFields = rawFields(fieldsContext);\n }\n const fieldsSpec = builder.applyHooks(\n this,\n \"GraphQLObjectType:fields\",\n this.extend(\n {},\n rawFields,\n `Default field included in newWithHooks call for '${\n rawSpec.name\n }'. ${inScope.__origin || \"\"}`\n ),\n fieldsContext,\n `|${rawSpec.name}`\n );\n // Finally, check through all the fields that they've all been processed; any that have not we should do so now.\n for (const fieldName in fieldsSpec) {\n const fieldSpec = fieldsSpec[fieldName];\n if (processedFields.indexOf(fieldSpec) < 0) {\n // We've not processed this yet; process it now!\n fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(\n fieldName,\n fieldSpec,\n {\n autoField: true, // We don't have any additional information\n }\n );\n }\n }\n return fieldsSpec;\n },\n };\n } else if (Type === GraphQLInputObjectType) {\n const commonContext = {\n type: \"GraphQLInputObjectType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLInputObjectType\",\n newSpec,\n commonContext,\n `|${newSpec.name}`\n );\n newSpec.fields = newSpec.fields || {};\n\n const rawSpec = newSpec;\n newSpec = {\n ...newSpec,\n fields: () => {\n const processedFields = [];\n const fieldsContext = {\n ...commonContext,\n Self,\n GraphQLInputObjectType: rawSpec,\n fieldWithHooks: ((fieldName, spec, fieldScope = {}) => {\n if (!isString(fieldName)) {\n throw new Error(\n \"It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is currently necessary.\"\n );\n }\n const context = {\n ...commonContext,\n Self,\n scope: extend(\n extend(\n { ...scope },\n {\n fieldName,\n },\n `Within context for GraphQLInputObjectType '${rawSpec.name}'`\n ),\n fieldScope,\n `Extending scope for field '${fieldName}' within context for GraphQLInputObjectType '${rawSpec.name}'`\n ),\n };\n let newSpec = spec;\n if (typeof newSpec === \"function\") {\n newSpec = newSpec(context);\n }\n newSpec = builder.applyHooks(\n this,\n \"GraphQLInputObjectType:fields:field\",\n newSpec,\n context,\n `|${getNameFromType(Self)}.fields.${fieldName}`\n );\n const finalSpec = newSpec;\n processedFields.push(finalSpec);\n return finalSpec;\n }: InputFieldWithHooksFunction),\n };\n let rawFields = rawSpec.fields;\n if (typeof rawFields === \"function\") {\n rawFields = rawFields(fieldsContext);\n }\n const fieldsSpec = builder.applyHooks(\n this,\n \"GraphQLInputObjectType:fields\",\n this.extend(\n {},\n rawFields,\n `Default field included in newWithHooks call for '${\n rawSpec.name\n }'. ${inScope.__origin || \"\"}`\n ),\n fieldsContext,\n `|${getNameFromType(Self)}`\n );\n // Finally, check through all the fields that they've all been processed; any that have not we should do so now.\n for (const fieldName in fieldsSpec) {\n const fieldSpec = fieldsSpec[fieldName];\n if (processedFields.indexOf(fieldSpec) < 0) {\n // We've not processed this yet; process it now!\n fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(\n fieldName,\n fieldSpec,\n {\n autoField: true, // We don't have any additional information\n }\n );\n }\n }\n return fieldsSpec;\n },\n };\n } else if (Type === GraphQLEnumType) {\n const commonContext = {\n type: \"GraphQLEnumType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLEnumType\",\n newSpec,\n commonContext,\n `|${newSpec.name}`\n );\n\n newSpec.values = builder.applyHooks(\n this,\n \"GraphQLEnumType:values\",\n newSpec.values,\n commonContext,\n `|${newSpec.name}`\n );\n const values = newSpec.values;\n newSpec.values = Object.keys(values).reduce((memo, valueKey) => {\n const value = values[valueKey];\n const newValue = builder.applyHooks(\n this,\n \"GraphQLEnumType:values:value\",\n value,\n commonContext,\n `|${newSpec.name}|${valueKey}`\n );\n memo[valueKey] = newValue;\n return memo;\n }, {});\n } else if (Type === GraphQLUnionType) {\n const commonContext = {\n type: \"GraphQLUnionType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLUnionType\",\n newSpec,\n { ...commonContext },\n `|${newSpec.name}`\n );\n\n const rawSpec = newSpec;\n newSpec = {\n ...newSpec,\n types: () => {\n const typesContext = {\n ...commonContext,\n Self,\n GraphQLUnionType: rawSpec,\n };\n let rawTypes = rawSpec.types || [];\n if (typeof rawTypes === \"function\") {\n rawTypes = rawTypes(typesContext);\n }\n return builder.applyHooks(\n this,\n \"GraphQLUnionType:types\",\n rawTypes,\n typesContext,\n `|${getNameFromType(Self)}`\n );\n },\n };\n }\n\n const finalSpec: ConfigType = newSpec;\n\n const Self: T = new Type(finalSpec);\n if (!(Self instanceof GraphQLSchema) && performNonEmptyFieldsCheck) {\n try {\n if (\n Self instanceof GraphQLInterfaceType ||\n Self instanceof GraphQLObjectType ||\n Self instanceof GraphQLInputObjectType\n ) {\n const _Self:\n | GraphQLInterfaceType\n | GraphQLInputObjectType\n | GraphQLObjectType = Self;\n if (typeof _Self.getFields === \"function\") {\n const fields = _Self.getFields();\n if (Object.keys(fields).length === 0) {\n // We require there's at least one field on GraphQLObjectType and GraphQLInputObjectType records\n return null;\n }\n }\n }\n } catch (e) {\n // This is the error we're expecting to handle:\n // https://github.com/graphql/graphql-js/blob/831598ba76f015078ecb6c5c1fbaf133302f3f8e/src/type/definition.js#L526-L531\n if (inScope && inScope.isRootQuery) {\n throw e;\n }\n const isProbablyAnEmptyObjectError = !!e.message.match(\n /function which returns such an object/\n );\n if (!isProbablyAnEmptyObjectError) {\n this.swallowError(e);\n }\n return null;\n }\n }\n\n this.scopeByType.set(Self, scope);\n if (finalSpec.name) {\n this.addType(\n Self,\n scope.__origin ||\n (this\n ? `'newWithHooks' call during hook '${this.status.currentHookName}'`\n : null)\n );\n }\n fieldDataGeneratorsByFieldNameByType.set(\n Self,\n fieldDataGeneratorsByFieldName\n );\n fieldArgDataGeneratorsByFieldNameByType.set(\n Self,\n fieldArgDataGeneratorsByFieldName\n );\n return Self;\n },\n fieldDataGeneratorsByType: fieldDataGeneratorsByFieldNameByType, // @deprecated\n fieldDataGeneratorsByFieldNameByType,\n fieldArgDataGeneratorsByFieldNameByType,\n inflection: {\n pluralize,\n singularize: pluralize.singular,\n upperCamelCase,\n camelCase,\n constantCase,\n\n // Built-in names (allows you to override these in the output schema)\n builtin: name => {\n /*\n * e.g.:\n *\n * graphile-build:\n *\n * - Query\n * - Mutation\n * - Subscription\n * - Node\n * - PageInfo\n *\n * graphile-build-pg:\n *\n * - Interval\n * - BigInt\n * - BigFloat\n * - BitString\n * - Point\n * - Date\n * - Datetime\n * - Time\n * - JSON\n * - UUID\n * - InternetAddress\n *\n * Other plugins may add their own builtins too; try and avoid conflicts!\n */\n return name;\n },\n\n // When converting a query field to a subscription (live query) field, this allows you to rename it\n live: name => name,\n\n // Try and make something a valid GraphQL 'Name'\n coerceToGraphQLName: (name: string) => {\n let resultingName = name;\n\n /*\n * Name is defined in GraphQL to match this regexp:\n *\n * /^[_A-Za-z][_0-9A-Za-z]*$/\n *\n * See: https://graphql.github.io/graphql-spec/June2018/#sec-Appendix-Grammar-Summary.Lexical-Tokens\n *\n * So if our 'name' starts with a digit, we must prefix it with\n * something. We'll just use an underscore.\n */\n if (resultingName.match(/^[0-9]/)) {\n resultingName = \"_\" + resultingName;\n }\n\n /*\n * Fields beginning with two underscores are reserved by the GraphQL\n * introspection systems, trim to just one.\n */\n resultingName = resultingName.replace(/^__+/g, \"_\");\n\n return resultingName;\n },\n },\n wrapDescription,\n swallowError,\n // resolveNode: EXPERIMENTAL, API might change!\n resolveNode,\n status: {\n currentHookName: null,\n currentHookEvent: null,\n },\n liveCoordinator: new LiveCoordinator(),\n scopeByType: new Map(),\n };\n}\n"],"file":"makeNewBuild.js"}
|
|
1
|
+
{"version":3,"sources":["../src/makeNewBuild.js"],"names":["recurseDataGeneratorsForFieldWarned","isString","str","isDev","indexOf","process","env","NODE_ENV","debug","hashCache","LRU","maxLength","hashFieldAlias","precomputed","get","hash","update","digest","set","getSafeAliasFromAlias","alias","length","startsWith","Error","getSafeAliasFromResolveInfo","resolveInfo","getNameFromType","Type","GraphQLSchema","name","GraphQLInterfaceType","GraphQLObjectType","GraphQLInputObjectType","GraphQLEnumType","GraphQLUnionType","getNamedType","isCompositeType","isAbstractType","graphql","mergeData","data","gen","ReturnType","arg","results","ensureArray","resultIndex","resultCount","result","keys","Object","i","l","k","value","newData","push","knownTypes","knownTypeNames","map","val","Array","isArray","ensureName","_fn","fn","displayName","enabled","console","trace","makeNewBuild","builder","allTypes","Int","GraphQLInt","Float","GraphQLFloat","String","GraphQLString","Boolean","GraphQLBoolean","ID","GraphQLID","allTypesSources","fieldDataGeneratorsByFieldNameByType","Map","fieldArgDataGeneratorsByFieldNameByType","options","graphileBuildVersion","version","versions","require","hasVersion","packageName","range","includePrerelease","packageVersion","semver","satisfies","parseResolveInfo","simplifyParsedResolveInfoFragmentWithType","getAliasFromResolveInfo","resolveAlias","_args","_context","addType","type","origin","newTypeSource","status","currentHookName","oldTypeSource","firstEntityDetails","chalk","magenta","secondEntityDetails","yellow","bold","getTypeByName","typeName","extend","newWithHooks","spec","inScope","performNonEmptyFieldsCheck","scope","warn","fieldDataGeneratorsByFieldName","fieldArgDataGeneratorsByFieldName","newSpec","applyHooks","addDataGeneratorForField","fieldName","Self","recurseDataGeneratorsForField","iKnowWhatIAmDoing","error","parsedResolveInfoFragment","rest","args","fields","StrippedType","argDataGeneratorsForSelfByFieldName","argDataGenerators","genIndex","genCount","local","typeFields","getFields","keyIndex","keyCount","field","gens","commonContext","rawSpec","interfaces","interfacesContext","rawInterfaces","processedFields","fieldsContext","fieldWithHooks","fieldScope","context","addDataGenerator","addArgDataGenerator","getDataFromParsedResolveInfoFragment","dgIndex","dgCount","e","finalSpec","FieldReturnType","returnType","rawFields","fieldsSpec","__origin","fieldSpec","autoField","values","reduce","memo","valueKey","newValue","types","typesContext","rawTypes","_Self","isRootQuery","isProbablyAnEmptyObjectError","message","match","swallowError","scopeByType","fieldDataGeneratorsByType","inflection","pluralize","singularize","singular","upperCamelCase","camelCase","constantCase","builtin","live","coerceToGraphQLName","resultingName","replace","wrapDescription","resolveNode","currentHookEvent","liveCoordinator","LiveCoordinator"],"mappings":";;;;;;;AAEA;;AAOA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AASA;;AACA;;AACA;;AAEA;;;;;;;;AAEA,IAAIA,mCAAmC,GAAG,KAA1C;;AAEA,MAAMC,QAAQ,GAAGC,GAAG,IAAI,OAAOA,GAAP,KAAe,QAAvC;;AACA,MAAMC,KAAK,GAAG,CAAC,MAAD,EAAS,aAAT,EAAwBC,OAAxB,CAAgCC,OAAO,CAACC,GAAR,CAAYC,QAA5C,KAAyD,CAAvE;AACA,MAAMC,KAAK,GAAG,oBAAa,gBAAb,CAAd;AAEA;;;;;;;;;AAQA,MAAMC,SAAS,GAAG,IAAIC,YAAJ,CAAQ;AAAEC,EAAAA,SAAS,EAAE;AAAb,CAAR,CAAlB;AAEA;;;;;;;;;;AASA,SAASC,cA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;;;;;;;;AAUA,YAAI8K,aAAa,CAACd,KAAd,CAAoB,QAApB,CAAJ,EAAmC;AACjCc,UAAAA,aAAa,GAAG,MAAMA,aAAtB;AACD;AAED;;;;;;AAIAA,QAAAA,aAAa,GAAGA,aAAa,CAACC,OAAd,CAAsB,OAAtB,EAA+B,GAA/B,CAAhB;AAEA,eAAOD,aAAP;AACD;AAnES,KA1wBP;AA+0BLE,IAAAA,eAAe,EAAfA,sBA/0BK;AAg1BLf,IAAAA,YAAY,EAAZA,qBAh1BK;AAi1BL;AACAgB,IAAAA,WAAW,EAAXA,oBAl1BK;AAm1BLjG,IAAAA,MAAM,EAAE;AACNC,MAAAA,eAAe,EAAE,IADX;AAENiG,MAAAA,gBAAgB,EAAE;AAFZ,KAn1BH;AAu1BLC,IAAAA,eAAe,EAAE,IAAIC,qBAAJ,EAv1BZ;AAw1BLlB,IAAAA,WAAW,EAAE,IAAI1G,GAAJ;AAx1BR,GAAP;AA01BD","sourcesContent":["// @flow\n\nimport * as graphql from \"graphql\";\nimport type {\n GraphQLNamedType,\n GraphQLInputField,\n GraphQLFieldResolver,\n GraphQLType,\n} from \"graphql\";\nimport {\n parseResolveInfo,\n simplifyParsedResolveInfoFragmentWithType,\n getAliasFromResolveInfo as rawGetAliasFromResolveInfo,\n} from \"graphql-parse-resolve-info\";\nimport debugFactory from \"debug\";\nimport type { ResolveTree } from \"graphql-parse-resolve-info\";\nimport pluralize from \"pluralize\";\nimport LRU from \"@graphile/lru\";\nimport semver from \"semver\";\nimport {\n upperCamelCase,\n camelCase,\n constantCase,\n wrapDescription,\n} from \"./utils\";\nimport swallowError from \"./swallowError\";\nimport resolveNode from \"./resolveNode\";\nimport { LiveCoordinator } from \"./Live\";\n\nimport type SchemaBuilder, {\n Build,\n Context,\n Scope,\n DataForType,\n} from \"./SchemaBuilder\";\n\nimport extend, { indent } from \"./extend\";\nimport chalk from \"chalk\";\nimport { createHash } from \"crypto\";\n\nimport { version } from \"../package.json\";\n\nlet recurseDataGeneratorsForFieldWarned = false;\n\nconst isString = str => typeof str === \"string\";\nconst isDev = [\"test\", \"development\"].indexOf(process.env.NODE_ENV) >= 0;\nconst debug = debugFactory(\"graphile-build\");\n\n/*\n * This should be more than enough for normal usage. If you come under a\n * sophisticated attack then the attacker can empty this of useful values (with\n * a lot of work) but because we use SHA1 hashes under the covers the aliases\n * will still be consistent even after the LRU cache is exhausted. And SHA1 can\n * produce half a million hashes per second on my machine, the LRU only gives\n * us a 10x speedup!\n */\nconst hashCache = new LRU({ maxLength: 100000 });\n\n/*\n * This function must never return a string longer than 56 characters.\n *\n * This function must only output alphanumeric and underscore characters.\n *\n * Collisions in SHA1 aren't problematic here (for us; they will be problematic\n * for the user deliberately causing them, but that's their own fault!), so\n * we'll happily take the performance boost over SHA256.\n */\nfunction hashFieldAlias(str) {\n const precomputed = hashCache.get(str);\n if (precomputed) return precomputed;\n const hash = createHash(\"sha1\").update(str).digest(\"hex\");\n hashCache.set(str, hash);\n return hash;\n}\n\n/*\n * This function may be replaced at any time, but all versions of it will\n * always return a representation of `alias` (a valid GraphQL identifier)\n * that:\n *\n * 1. won't conflict with normal GraphQL field names\n * 2. won't be over 60 characters long (allows for systems with alias length limits, such as PG)\n * 3. will give the same value when called multiple times within the same GraphQL query\n * 4. matches the regex /^[@!-_A-Za-z0-9]+$/\n * 5. will not be prefixed with `__` (as that will conflict with other Graphile internals)\n *\n * It does not guarantee that this alias will be human readable!\n */\nfunction getSafeAliasFromAlias(alias) {\n if (alias.length <= 60 && !alias.startsWith(\"@\")) {\n // Use the `@` to prevent conflicting with normal GraphQL field names, but otherwise let it through verbatim.\n return `@${alias}`;\n } else if (alias.length > 1024) {\n throw new Error(\n `GraphQL alias '${alias}' is too long, use shorter aliases (max length 1024).`\n );\n } else {\n return `@@${hashFieldAlias(alias)}`;\n }\n}\n\n/*\n * This provides a \"safe\" version of the alias from ResolveInfo, guaranteed to\n * never be longer than 60 characters. This makes it suitable as a PostgreSQL\n * identifier.\n */\nfunction getSafeAliasFromResolveInfo(resolveInfo) {\n const alias = rawGetAliasFromResolveInfo(resolveInfo);\n return getSafeAliasFromAlias(alias);\n}\n\ntype MetaData = {\n [string]: Array<mixed>,\n};\ntype DataGeneratorFunction = (\n parsedResolveInfoFragment: ResolveTree,\n ReturnType: GraphQLType,\n ...args: Array<mixed>\n) => Array<MetaData>;\n\ntype FieldSpecIsh = {\n type?: GraphQLType,\n args?: {},\n resolve?: GraphQLFieldResolver<*, *>,\n deprecationReason?: string,\n description?: ?string,\n};\n\ntype ContextAndGenerators =\n | Context\n | {\n addDataGenerator: DataGeneratorFunction => void,\n addArgDataGenerator: DataGeneratorFunction => void,\n getDataFromParsedResolveInfoFragment: (\n parsedResolveInfoFragment: ResolveTree,\n Type: GraphQLType\n ) => DataForType,\n };\n\nexport type FieldWithHooksFunction = (\n fieldName: string,\n spec: FieldSpecIsh | (ContextAndGenerators => FieldSpecIsh),\n fieldScope?: {}\n) => {};\n\nexport type InputFieldWithHooksFunction = (\n fieldName: string,\n spec: GraphQLInputField,\n fieldScope?: {}\n) => GraphQLInputField;\n\nfunction getNameFromType(Type: GraphQLNamedType | GraphQLSchema) {\n if (Type instanceof GraphQLSchema) {\n return \"schema\";\n } else {\n return Type.name;\n }\n}\n\nconst {\n GraphQLSchema,\n GraphQLInterfaceType,\n GraphQLObjectType,\n GraphQLInputObjectType,\n GraphQLEnumType,\n GraphQLUnionType,\n getNamedType,\n isCompositeType,\n isAbstractType,\n} = graphql;\n\nconst mergeData = (\n data: MetaData,\n gen: DataGeneratorFunction,\n ReturnType,\n arg\n) => {\n const results: ?Array<MetaData> = ensureArray<MetaData>(\n gen(arg, ReturnType, data)\n );\n if (!results) {\n return;\n }\n for (\n let resultIndex = 0, resultCount = results.length;\n resultIndex < resultCount;\n resultIndex++\n ) {\n const result: MetaData = results[resultIndex];\n const keys = Object.keys(result);\n for (let i = 0, l = keys.length; i < l; i++) {\n const k = keys[i];\n data[k] = data[k] || [];\n const value: mixed = result[k];\n const newData: ?Array<mixed> = ensureArray<mixed>(value);\n if (newData) {\n data[k].push(...newData);\n }\n }\n }\n};\n\nconst knownTypes = [\n GraphQLSchema,\n GraphQLObjectType,\n GraphQLInputObjectType,\n GraphQLEnumType,\n GraphQLUnionType,\n];\nconst knownTypeNames = knownTypes.map(k => k.name);\n\nfunction ensureArray<T>(val: null | T | Array<T>): void | Array<T> {\n if (val == null) {\n return;\n } else if (Array.isArray(val)) {\n // $FlowFixMe\n return (val: Array<T>);\n } else {\n return ([val]: Array<T>);\n }\n}\n\n// eslint-disable-next-line no-unused-vars\nlet ensureName = _fn => {};\nif ([\"development\", \"test\"].indexOf(process.env.NODE_ENV) >= 0) {\n ensureName = fn => {\n // $FlowFixMe: displayName\n if (isDev && !fn.displayName && !fn.name && debug.enabled) {\n // eslint-disable-next-line no-console\n console.trace(\n \"WARNING: you've added a function with no name as an argDataGenerator, doing so may make debugging more challenging\"\n );\n }\n };\n}\n\nexport default function makeNewBuild(builder: SchemaBuilder): { ...Build } {\n const allTypes = {\n Int: graphql.GraphQLInt,\n Float: graphql.GraphQLFloat,\n String: graphql.GraphQLString,\n Boolean: graphql.GraphQLBoolean,\n ID: graphql.GraphQLID,\n };\n const allTypesSources = {\n Int: \"GraphQL Built-in\",\n Float: \"GraphQL Built-in\",\n String: \"GraphQL Built-in\",\n Boolean: \"GraphQL Built-in\",\n ID: \"GraphQL Built-in\",\n };\n\n // Every object type gets fieldData associated with each of its\n // fields.\n\n // When a field is defined, it may add to this field data.\n\n // When something resolves referencing this type, the resolver may\n // request the fieldData, e.g. to perform optimisations.\n\n // fieldData is an object whose keys are the fields on this\n // GraphQLObjectType and whose values are an object (whose keys are\n // arbitrary namespaced keys and whose values are arrays of\n // information of this kind)\n const fieldDataGeneratorsByFieldNameByType = new Map();\n const fieldArgDataGeneratorsByFieldNameByType = new Map();\n\n return {\n options: builder.options,\n graphileBuildVersion: version,\n versions: {\n graphql: require(\"graphql/package.json\").version,\n \"graphile-build\": version,\n },\n hasVersion(\n packageName: string,\n range: string,\n options?: { includePrerelease?: boolean } = { includePrerelease: true }\n ): boolean {\n const packageVersion = this.versions[packageName];\n if (!packageVersion) return false;\n return semver.satisfies(packageVersion, range, options);\n },\n graphql,\n parseResolveInfo,\n simplifyParsedResolveInfoFragmentWithType,\n getSafeAliasFromAlias,\n getAliasFromResolveInfo: getSafeAliasFromResolveInfo, // DEPRECATED: do not use this!\n getSafeAliasFromResolveInfo,\n resolveAlias(data, _args, _context, resolveInfo) {\n const alias = getSafeAliasFromResolveInfo(resolveInfo);\n return data[alias];\n },\n addType(type: GraphQLNamedType, origin?: ?string): void {\n if (!type.name) {\n throw new Error(\n `addType must only be called with named types, try using require('graphql').getNamedType`\n );\n }\n const newTypeSource =\n origin ||\n // 'this' is typically only available after the build is finalized\n (this\n ? `'addType' call during hook '${this.status.currentHookName}'`\n : null);\n if (allTypes[type.name]) {\n if (allTypes[type.name] !== type) {\n const oldTypeSource = allTypesSources[type.name];\n const firstEntityDetails = !oldTypeSource\n ? \"The first type was registered from an unknown origin.\"\n : `The first entity was:\\n\\n${indent(\n chalk.magenta(oldTypeSource)\n )}`;\n const secondEntityDetails = !newTypeSource\n ? \"The second type was registered from an unknown origin.\"\n : `The second entity was:\\n\\n${indent(\n chalk.yellow(newTypeSource)\n )}`;\n throw new Error(\n `A type naming conflict has occurred - two entities have tried to define the same type '${chalk.bold(\n type.name\n )}'.\\n\\n${indent(firstEntityDetails)}\\n\\n${indent(\n secondEntityDetails\n )}`\n );\n }\n } else {\n allTypes[type.name] = type;\n allTypesSources[type.name] = newTypeSource;\n }\n },\n getTypeByName(typeName) {\n return allTypes[typeName];\n },\n extend,\n newWithHooks<T: GraphQLNamedType | GraphQLSchema, ConfigType: *>(\n Type: Class<T>,\n spec: ConfigType,\n inScope: Scope,\n performNonEmptyFieldsCheck = false\n ): ?T {\n const scope = inScope || {};\n if (!inScope) {\n // eslint-disable-next-line no-console\n console.warn(\n `No scope was provided to new ${Type.name}[name=${spec.name}], it's highly recommended that you add a scope so other hooks can easily reference your object - please check usage of 'newWithHooks'. To mute this message, just pass an empty object.`\n );\n }\n if (!Type) {\n throw new Error(\"No type specified!\");\n }\n if (!this.newWithHooks) {\n throw new Error(\n \"Please do not generate the schema during the build building phase, use 'init' instead\"\n );\n }\n const fieldDataGeneratorsByFieldName = {};\n const fieldArgDataGeneratorsByFieldName = {};\n let newSpec = spec;\n if (\n knownTypes.indexOf(Type) === -1 &&\n knownTypeNames.indexOf(Type.name) >= 0\n ) {\n throw new Error(\n `GraphQL conflict for '${Type.name}' detected! Multiple versions of graphql exist in your node_modules?`\n );\n }\n if (Type === GraphQLSchema) {\n newSpec = builder.applyHooks(this, \"GraphQLSchema\", newSpec, {\n type: \"GraphQLSchema\",\n scope,\n });\n } else if (Type === GraphQLObjectType) {\n const addDataGeneratorForField = (\n fieldName,\n fn: DataGeneratorFunction\n ) => {\n // $FlowFixMe: displayName\n fn.displayName =\n // $FlowFixMe: displayName\n fn.displayName ||\n `${getNameFromType(Self)}:${fieldName}[${fn.name || \"anonymous\"}]`;\n fieldDataGeneratorsByFieldName[fieldName] =\n fieldDataGeneratorsByFieldName[fieldName] || [];\n fieldDataGeneratorsByFieldName[fieldName].push(fn);\n };\n const recurseDataGeneratorsForField = (\n fieldName,\n iKnowWhatIAmDoing\n ) => {\n /*\n * Recursing data generators is not safe in general; however there\n * are certain exceptions - for example when you know there are no\n * \"dynamic\" data generator fields - e.g. where the GraphQL alias is\n * not used at all. In PostGraphile the only case of this is the\n * PageInfo object as none of the fields accept arguments, and they\n * do not rely on the GraphQL query alias to store the result.\n */\n if (!iKnowWhatIAmDoing && !recurseDataGeneratorsForFieldWarned) {\n recurseDataGeneratorsForFieldWarned = true;\n // eslint-disable-next-line no-console\n console.error(\n \"Use of `recurseDataGeneratorsForField` is NOT SAFE. e.g. `{n1: node { a: field1 }, n2: node { a: field2 } }` cannot resolve correctly.\"\n );\n }\n const fn = (parsedResolveInfoFragment, ReturnType, ...rest) => {\n const { args } = parsedResolveInfoFragment;\n const { fields } = this.simplifyParsedResolveInfoFragmentWithType(\n parsedResolveInfoFragment,\n ReturnType\n );\n const results = [];\n const StrippedType: GraphQLNamedType = getNamedType(ReturnType);\n const fieldDataGeneratorsByFieldName = fieldDataGeneratorsByFieldNameByType.get(\n StrippedType\n );\n const argDataGeneratorsForSelfByFieldName = fieldArgDataGeneratorsByFieldNameByType.get(\n Self\n );\n if (argDataGeneratorsForSelfByFieldName) {\n const argDataGenerators =\n argDataGeneratorsForSelfByFieldName[fieldName];\n for (\n let genIndex = 0, genCount = argDataGenerators.length;\n genIndex < genCount;\n genIndex++\n ) {\n const gen = argDataGenerators[genIndex];\n const local = ensureArray(gen(args, ReturnType, ...rest));\n if (local) {\n results.push(...local);\n }\n }\n }\n if (\n fieldDataGeneratorsByFieldName &&\n isCompositeType(StrippedType) &&\n !isAbstractType(StrippedType)\n ) {\n const typeFields = StrippedType.getFields();\n const keys = Object.keys(fields);\n for (\n let keyIndex = 0, keyCount = keys.length;\n keyIndex < keyCount;\n keyIndex++\n ) {\n const alias = keys[keyIndex];\n const field = fields[alias];\n // Run generators with `field` as the `parsedResolveInfoFragment`, pushing results to `results`\n const gens = fieldDataGeneratorsByFieldName[field.name];\n if (gens) {\n for (\n let genIndex = 0, genCount = gens.length;\n genIndex < genCount;\n genIndex++\n ) {\n const gen = gens[genIndex];\n const local = ensureArray(\n gen(field, typeFields[field.name].type, ...rest)\n );\n if (local) {\n results.push(...local);\n }\n }\n }\n }\n }\n return results;\n };\n fn.displayName = `recurseDataGeneratorsForField(${getNameFromType(\n Self\n )}:${fieldName})`;\n addDataGeneratorForField(fieldName, fn);\n // get type from field, get\n };\n\n const commonContext = {\n type: \"GraphQLObjectType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLObjectType\",\n newSpec,\n {\n ...commonContext,\n addDataGeneratorForField,\n recurseDataGeneratorsForField,\n },\n `|${newSpec.name}`\n );\n\n const rawSpec = newSpec;\n newSpec = {\n ...newSpec,\n interfaces: () => {\n const interfacesContext = {\n ...commonContext,\n Self,\n GraphQLObjectType: rawSpec,\n };\n let rawInterfaces = rawSpec.interfaces || [];\n if (typeof rawInterfaces === \"function\") {\n rawInterfaces = rawInterfaces(interfacesContext);\n }\n return builder.applyHooks(\n this,\n \"GraphQLObjectType:interfaces\",\n rawInterfaces,\n interfacesContext,\n `|${getNameFromType(Self)}`\n );\n },\n fields: () => {\n const processedFields = [];\n const fieldsContext = {\n ...commonContext,\n addDataGeneratorForField,\n recurseDataGeneratorsForField,\n Self,\n GraphQLObjectType: rawSpec,\n fieldWithHooks: ((fieldName, spec, fieldScope) => {\n if (!isString(fieldName)) {\n throw new Error(\n \"It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is currently necessary.\"\n );\n }\n if (!fieldScope) {\n throw new Error(\n \"All calls to `fieldWithHooks` must specify a `fieldScope` \" +\n \"argument that gives additional context about the field so \" +\n \"that further plugins may more easily understand the field. \" +\n \"Keys within this object should contain the phrase 'field' \" +\n \"since they will be merged into the parent objects scope and \" +\n \"are not allowed to clash. If you really have no additional \" +\n \"information to give, please just pass `{}`.\"\n );\n }\n\n const argDataGenerators = [];\n fieldArgDataGeneratorsByFieldName[\n fieldName\n ] = argDataGenerators;\n\n let newSpec = spec;\n const context = {\n ...commonContext,\n Self,\n addDataGenerator(fn) {\n return addDataGeneratorForField(fieldName, fn);\n },\n addArgDataGenerator(fn) {\n ensureName(fn);\n argDataGenerators.push(fn);\n },\n getDataFromParsedResolveInfoFragment: (\n parsedResolveInfoFragment,\n ReturnType\n ): DataForType => {\n const Type: GraphQLNamedType = getNamedType(ReturnType);\n const data = {};\n\n const {\n fields,\n args,\n } = this.simplifyParsedResolveInfoFragmentWithType(\n parsedResolveInfoFragment,\n ReturnType\n );\n\n // Args -> argDataGenerators\n for (\n let dgIndex = 0, dgCount = argDataGenerators.length;\n dgIndex < dgCount;\n dgIndex++\n ) {\n const gen = argDataGenerators[dgIndex];\n try {\n mergeData(data, gen, ReturnType, args);\n } catch (e) {\n debug(\n \"Failed to execute argDataGenerator '%s' on %s of %s\",\n gen.displayName || gen.name || \"anonymous\",\n fieldName,\n getNameFromType(Self)\n );\n throw e;\n }\n }\n\n // finalSpec.type -> fieldData\n if (!finalSpec) {\n throw new Error(\n \"It's too early to call this! Call from within resolve\"\n );\n }\n const fieldDataGeneratorsByFieldName = fieldDataGeneratorsByFieldNameByType.get(\n Type\n );\n if (\n fieldDataGeneratorsByFieldName &&\n isCompositeType(Type) &&\n !isAbstractType(Type)\n ) {\n const typeFields = Type.getFields();\n const keys = Object.keys(fields);\n for (\n let keyIndex = 0, keyCount = keys.length;\n keyIndex < keyCount;\n keyIndex++\n ) {\n const alias = keys[keyIndex];\n const field = fields[alias];\n const gens = fieldDataGeneratorsByFieldName[field.name];\n if (gens) {\n const FieldReturnType = typeFields[field.name].type;\n for (let i = 0, l = gens.length; i < l; i++) {\n mergeData(data, gens[i], FieldReturnType, field);\n }\n }\n }\n }\n return data;\n },\n scope: extend(\n extend(\n { ...scope },\n {\n fieldName,\n },\n `Within context for GraphQLObjectType '${rawSpec.name}'`\n ),\n fieldScope,\n `Extending scope for field '${fieldName}' within context for GraphQLObjectType '${rawSpec.name}'`\n ),\n };\n if (typeof newSpec === \"function\") {\n newSpec = newSpec(context);\n }\n newSpec = builder.applyHooks(\n this,\n \"GraphQLObjectType:fields:field\",\n newSpec,\n context,\n `|${getNameFromType(Self)}.fields.${fieldName}`\n );\n newSpec.args = newSpec.args || {};\n newSpec = {\n ...newSpec,\n args: builder.applyHooks(\n this,\n \"GraphQLObjectType:fields:field:args\",\n newSpec.args,\n {\n ...context,\n field: newSpec,\n returnType: newSpec.type,\n },\n `|${getNameFromType(Self)}.fields.${fieldName}`\n ),\n };\n const finalSpec = newSpec;\n processedFields.push(finalSpec);\n return finalSpec;\n }: FieldWithHooksFunction),\n };\n let rawFields = rawSpec.fields || {};\n if (typeof rawFields === \"function\") {\n rawFields = rawFields(fieldsContext);\n }\n const fieldsSpec = builder.applyHooks(\n this,\n \"GraphQLObjectType:fields\",\n this.extend(\n {},\n rawFields,\n `Default field included in newWithHooks call for '${\n rawSpec.name\n }'. ${inScope.__origin || \"\"}`\n ),\n fieldsContext,\n `|${rawSpec.name}`\n );\n // Finally, check through all the fields that they've all been processed; any that have not we should do so now.\n for (const fieldName in fieldsSpec) {\n const fieldSpec = fieldsSpec[fieldName];\n if (processedFields.indexOf(fieldSpec) < 0) {\n // We've not processed this yet; process it now!\n fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(\n fieldName,\n fieldSpec,\n {\n autoField: true, // We don't have any additional information\n }\n );\n }\n }\n return fieldsSpec;\n },\n };\n } else if (Type === GraphQLInputObjectType) {\n const commonContext = {\n type: \"GraphQLInputObjectType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLInputObjectType\",\n newSpec,\n commonContext,\n `|${newSpec.name}`\n );\n newSpec.fields = newSpec.fields || {};\n\n const rawSpec = newSpec;\n newSpec = {\n ...newSpec,\n fields: () => {\n const processedFields = [];\n const fieldsContext = {\n ...commonContext,\n Self,\n GraphQLInputObjectType: rawSpec,\n fieldWithHooks: ((fieldName, spec, fieldScope = {}) => {\n if (!isString(fieldName)) {\n throw new Error(\n \"It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is currently necessary.\"\n );\n }\n const context = {\n ...commonContext,\n Self,\n scope: extend(\n extend(\n { ...scope },\n {\n fieldName,\n },\n `Within context for GraphQLInputObjectType '${rawSpec.name}'`\n ),\n fieldScope,\n `Extending scope for field '${fieldName}' within context for GraphQLInputObjectType '${rawSpec.name}'`\n ),\n };\n let newSpec = spec;\n if (typeof newSpec === \"function\") {\n newSpec = newSpec(context);\n }\n newSpec = builder.applyHooks(\n this,\n \"GraphQLInputObjectType:fields:field\",\n newSpec,\n context,\n `|${getNameFromType(Self)}.fields.${fieldName}`\n );\n const finalSpec = newSpec;\n processedFields.push(finalSpec);\n return finalSpec;\n }: InputFieldWithHooksFunction),\n };\n let rawFields = rawSpec.fields;\n if (typeof rawFields === \"function\") {\n rawFields = rawFields(fieldsContext);\n }\n const fieldsSpec = builder.applyHooks(\n this,\n \"GraphQLInputObjectType:fields\",\n this.extend(\n {},\n rawFields,\n `Default field included in newWithHooks call for '${\n rawSpec.name\n }'. ${inScope.__origin || \"\"}`\n ),\n fieldsContext,\n `|${getNameFromType(Self)}`\n );\n // Finally, check through all the fields that they've all been processed; any that have not we should do so now.\n for (const fieldName in fieldsSpec) {\n const fieldSpec = fieldsSpec[fieldName];\n if (processedFields.indexOf(fieldSpec) < 0) {\n // We've not processed this yet; process it now!\n fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(\n fieldName,\n fieldSpec,\n {\n autoField: true, // We don't have any additional information\n }\n );\n }\n }\n return fieldsSpec;\n },\n };\n } else if (Type === GraphQLEnumType) {\n const commonContext = {\n type: \"GraphQLEnumType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLEnumType\",\n newSpec,\n commonContext,\n `|${newSpec.name}`\n );\n\n newSpec.values = builder.applyHooks(\n this,\n \"GraphQLEnumType:values\",\n newSpec.values,\n commonContext,\n `|${newSpec.name}`\n );\n const values = newSpec.values;\n newSpec.values = Object.keys(values).reduce((memo, valueKey) => {\n const value = values[valueKey];\n const newValue = builder.applyHooks(\n this,\n \"GraphQLEnumType:values:value\",\n value,\n commonContext,\n `|${newSpec.name}|${valueKey}`\n );\n memo[valueKey] = newValue;\n return memo;\n }, {});\n } else if (Type === GraphQLUnionType) {\n const commonContext = {\n type: \"GraphQLUnionType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLUnionType\",\n newSpec,\n { ...commonContext },\n `|${newSpec.name}`\n );\n\n const rawSpec = newSpec;\n newSpec = {\n ...newSpec,\n types: () => {\n const typesContext = {\n ...commonContext,\n Self,\n GraphQLUnionType: rawSpec,\n };\n let rawTypes = rawSpec.types || [];\n if (typeof rawTypes === \"function\") {\n rawTypes = rawTypes(typesContext);\n }\n return builder.applyHooks(\n this,\n \"GraphQLUnionType:types\",\n rawTypes,\n typesContext,\n `|${getNameFromType(Self)}`\n );\n },\n };\n } else if (Type === GraphQLInterfaceType) {\n const commonContext = {\n type: \"GraphQLInterfaceType\",\n scope,\n };\n newSpec = builder.applyHooks(\n this,\n \"GraphQLInterfaceType\",\n newSpec,\n commonContext,\n `|${newSpec.name}`\n );\n\n const rawSpec = newSpec;\n newSpec = {\n ...newSpec,\n fields: () => {\n const processedFields = [];\n const fieldsContext = {\n ...commonContext,\n Self,\n GraphQLInterfaceType: rawSpec,\n fieldWithHooks: ((fieldName, spec, fieldScope) => {\n if (!isString(fieldName)) {\n throw new Error(\n \"It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is currently necessary.\"\n );\n }\n if (!fieldScope) {\n throw new Error(\n \"All calls to `fieldWithHooks` must specify a `fieldScope` \" +\n \"argument that gives additional context about the field so \" +\n \"that further plugins may more easily understand the field. \" +\n \"Keys within this object should contain the phrase 'field' \" +\n \"since they will be merged into the parent objects scope and \" +\n \"are not allowed to clash. If you really have no additional \" +\n \"information to give, please just pass `{}`.\"\n );\n }\n\n let newSpec = spec;\n const context = {\n ...commonContext,\n Self,\n scope: extend(\n extend(\n { ...scope },\n {\n fieldName,\n },\n `Within context for GraphQLInterfaceType '${rawSpec.name}'`\n ),\n fieldScope,\n `Extending scope for field '${fieldName}' within context for GraphQLInterfaceType '${rawSpec.name}'`\n ),\n };\n if (typeof newSpec === \"function\") {\n newSpec = newSpec(context);\n }\n newSpec = builder.applyHooks(\n this,\n \"GraphQLInterfaceType:fields:field\",\n newSpec,\n context,\n `|${getNameFromType(Self)}.fields.${fieldName}`\n );\n newSpec.args = newSpec.args || {};\n newSpec = {\n ...newSpec,\n args: builder.applyHooks(\n this,\n \"GraphQLInterfaceType:fields:field:args\",\n newSpec.args,\n {\n ...context,\n field: newSpec,\n returnType: newSpec.type,\n },\n `|${getNameFromType(Self)}.fields.${fieldName}`\n ),\n };\n const finalSpec = newSpec;\n processedFields.push(finalSpec);\n return finalSpec;\n }: FieldWithHooksFunction),\n };\n let rawFields = rawSpec.fields || {};\n if (typeof rawFields === \"function\") {\n rawFields = rawFields(fieldsContext);\n }\n const fieldsSpec = builder.applyHooks(\n this,\n \"GraphQLInterfaceType:fields\",\n this.extend(\n {},\n rawFields,\n `Default field included in newWithHooks call for '${\n rawSpec.name\n }'. ${inScope.__origin || \"\"}`\n ),\n fieldsContext,\n `|${rawSpec.name}`\n );\n // Finally, check through all the fields that they've all been processed; any that have not we should do so now.\n for (const fieldName in fieldsSpec) {\n const fieldSpec = fieldsSpec[fieldName];\n if (processedFields.indexOf(fieldSpec) < 0) {\n // We've not processed this yet; process it now!\n fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(\n fieldName,\n fieldSpec,\n {\n autoField: true, // We don't have any additional information\n }\n );\n }\n }\n return fieldsSpec;\n },\n };\n }\n\n const finalSpec: ConfigType = newSpec;\n\n const Self: T = new Type(finalSpec);\n if (!(Self instanceof GraphQLSchema) && performNonEmptyFieldsCheck) {\n try {\n if (\n Self instanceof GraphQLInterfaceType ||\n Self instanceof GraphQLObjectType ||\n Self instanceof GraphQLInputObjectType\n ) {\n const _Self:\n | GraphQLInterfaceType\n | GraphQLInputObjectType\n | GraphQLObjectType = Self;\n if (typeof _Self.getFields === \"function\") {\n const fields = _Self.getFields();\n if (Object.keys(fields).length === 0) {\n // We require there's at least one field on GraphQLObjectType and GraphQLInputObjectType records\n return null;\n }\n }\n }\n } catch (e) {\n // This is the error we're expecting to handle:\n // https://github.com/graphql/graphql-js/blob/831598ba76f015078ecb6c5c1fbaf133302f3f8e/src/type/definition.js#L526-L531\n if (inScope && inScope.isRootQuery) {\n throw e;\n }\n const isProbablyAnEmptyObjectError = !!e.message.match(\n /function which returns such an object/\n );\n if (!isProbablyAnEmptyObjectError) {\n this.swallowError(e);\n }\n return null;\n }\n }\n\n this.scopeByType.set(Self, scope);\n if (finalSpec.name) {\n this.addType(\n Self,\n scope.__origin ||\n (this\n ? `'newWithHooks' call during hook '${this.status.currentHookName}'`\n : null)\n );\n }\n fieldDataGeneratorsByFieldNameByType.set(\n Self,\n fieldDataGeneratorsByFieldName\n );\n fieldArgDataGeneratorsByFieldNameByType.set(\n Self,\n fieldArgDataGeneratorsByFieldName\n );\n return Self;\n },\n fieldDataGeneratorsByType: fieldDataGeneratorsByFieldNameByType, // @deprecated\n fieldDataGeneratorsByFieldNameByType,\n fieldArgDataGeneratorsByFieldNameByType,\n inflection: {\n pluralize,\n singularize: pluralize.singular,\n upperCamelCase,\n camelCase,\n constantCase,\n\n // Built-in names (allows you to override these in the output schema)\n builtin: name => {\n /*\n * e.g.:\n *\n * graphile-build:\n *\n * - Query\n * - Mutation\n * - Subscription\n * - Node\n * - PageInfo\n *\n * graphile-build-pg:\n *\n * - Interval\n * - BigInt\n * - BigFloat\n * - BitString\n * - Point\n * - Date\n * - Datetime\n * - Time\n * - JSON\n * - UUID\n * - InternetAddress\n *\n * Other plugins may add their own builtins too; try and avoid conflicts!\n */\n return name;\n },\n\n // When converting a query field to a subscription (live query) field, this allows you to rename it\n live: name => name,\n\n // Try and make something a valid GraphQL 'Name'\n coerceToGraphQLName: (name: string) => {\n let resultingName = name;\n\n /*\n * Name is defined in GraphQL to match this regexp:\n *\n * /^[_A-Za-z][_0-9A-Za-z]*$/\n *\n * See: https://graphql.github.io/graphql-spec/June2018/#sec-Appendix-Grammar-Summary.Lexical-Tokens\n *\n * So if our 'name' starts with a digit, we must prefix it with\n * something. We'll just use an underscore.\n */\n if (resultingName.match(/^[0-9]/)) {\n resultingName = \"_\" + resultingName;\n }\n\n /*\n * Fields beginning with two underscores are reserved by the GraphQL\n * introspection systems, trim to just one.\n */\n resultingName = resultingName.replace(/^__+/g, \"_\");\n\n return resultingName;\n },\n },\n wrapDescription,\n swallowError,\n // resolveNode: EXPERIMENTAL, API might change!\n resolveNode,\n status: {\n currentHookName: null,\n currentHookEvent: null,\n },\n liveCoordinator: new LiveCoordinator(),\n scopeByType: new Map(),\n };\n}\n"],"file":"makeNewBuild.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-build",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"description": "Build a GraphQL schema from plugins",
|
|
5
5
|
"main": "node8plus/index.js",
|
|
6
6
|
"types": "node8plus/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/graphile/graphile-
|
|
14
|
+
"url": "git+https://github.com/graphile/graphile-engine.git"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"graphile",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"author": "Benjie Gillam <code@benjiegillam.com>",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"bugs": {
|
|
29
|
-
"url": "https://github.com/graphile/graphile-
|
|
29
|
+
"url": "https://github.com/graphile/graphile-engine/issues"
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://graphile.org/graphile-build/",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@graphile/lru": "4.
|
|
33
|
+
"@graphile/lru": "4.11.0",
|
|
34
34
|
"chalk": "^2.4.2",
|
|
35
35
|
"debug": "^4.1.1",
|
|
36
|
-
"graphql-parse-resolve-info": "4.
|
|
36
|
+
"graphql-parse-resolve-info": "4.11.0",
|
|
37
37
|
"iterall": "^1.2.2",
|
|
38
38
|
"lodash": ">=4 <5",
|
|
39
39
|
"lru-cache": "^5.0.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"node8plus",
|
|
58
58
|
"index.js"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "742133b9064cd64d61e45edc981261a036d56c7f"
|
|
61
61
|
}
|