graphile-build 4.4.4 → 4.5.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/LICENSE.md +1 -3
- package/README.md +2 -1
- package/node8plus/Live.d.ts +5 -2
- package/node8plus/Live.js +72 -77
- package/node8plus/Live.js.flow +72 -75
- package/node8plus/Live.js.map +1 -1
- package/node8plus/SchemaBuilder.d.ts +1 -0
- package/node8plus/SchemaBuilder.js +16 -3
- package/node8plus/SchemaBuilder.js.flow +14 -0
- package/node8plus/SchemaBuilder.js.map +1 -1
- package/node8plus/callbackToAsyncIterator.js.flow +2 -2
- package/node8plus/callbackToAsyncIterator.js.map +1 -1
- package/node8plus/extend.js +1 -3
- package/node8plus/extend.js.flow +1 -3
- package/node8plus/extend.js.map +1 -1
- package/node8plus/index.d.ts +3 -8
- package/node8plus/index.js +2 -1
- package/node8plus/index.js.flow +1 -0
- package/node8plus/index.js.map +1 -1
- package/node8plus/makeNewBuild.js +12 -6
- package/node8plus/makeNewBuild.js.flow +21 -27
- package/node8plus/makeNewBuild.js.map +1 -1
- package/node8plus/plugins/ClientMutationIdDescriptionPlugin.js.flow +2 -4
- package/node8plus/plugins/ClientMutationIdDescriptionPlugin.js.map +1 -1
- package/node8plus/plugins/NodePlugin.js.flow +1 -3
- package/node8plus/plugins/NodePlugin.js.map +1 -1
- package/node8plus/plugins/SwallowErrorsPlugin.js +0 -1
- package/node8plus/plugins/SwallowErrorsPlugin.js.flow +0 -1
- package/node8plus/plugins/SwallowErrorsPlugin.js.map +1 -1
- package/package.json +7 -13
|
@@ -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","triggerChange","emit","e","error","on","unwatchSchema","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;;AA2GA,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;A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ACR,WAAKD,KAAL,GAAa,KAAb;AACD;AACF;;AAjbsC;;eAob1BL,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 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}/${(provides &&\n provides.length &&\n provides.join(\"+\")) ||\n fn.displayName ||\n fn.name ||\n \"unnamed\"}`;\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 '${hook.displayName ||\n hook.name ||\n \"anonymous\"}' 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 this.triggerChange = () => {\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 for (const fn of this.watchers) {\n await fn(this.triggerChange);\n }\n if (listener) {\n this.on(\"schema\", listener);\n }\n this.emit(\"schema\", this.buildSchema());\n this._watching = true;\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","_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","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;;AA2GA,MAAMC,aAAN,SAA4BC,eAA5B,CAAyC;AAgBvCC,EAAAA,WAAW,CAACC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ApB;AAEA,WAAK/E,SAAL,GAAiB,IAAjB;AACD,KA1CD,SA0CU;AACR,WAAKD,KAAL,GAAa,KAAb;AACD;AACF;;AAED,QAAMiG,aAAN,GAAsB;AACpB,QAAI,KAAKjG,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,YAAMyF,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,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;;AA/bsC;;eAkc1BL,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 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}/${(provides &&\n provides.length &&\n provides.join(\"+\")) ||\n fn.displayName ||\n fn.name ||\n \"unnamed\"}`;\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 '${hook.displayName ||\n hook.name ||\n \"anonymous\"}' 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 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 `triggerChange`\n // calls should be honoured.\n ignoreChangeTriggers = false;\n\n if (listener) {\n this.on(\"schema\", listener);\n }\n this.emit(\"schema\", this.buildSchema());\n\n this._watching = true;\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"}
|
|
@@ -73,7 +73,7 @@ export default function callbackToAsyncIterator<
|
|
|
73
73
|
emptyQueue();
|
|
74
74
|
return Promise.resolve({ value: undefined, done: true });
|
|
75
75
|
},
|
|
76
|
-
throw(error) {
|
|
76
|
+
throw(error: Error) {
|
|
77
77
|
emptyQueue();
|
|
78
78
|
onError(error);
|
|
79
79
|
return Promise.reject(error);
|
|
@@ -91,7 +91,7 @@ export default function callbackToAsyncIterator<
|
|
|
91
91
|
return() {
|
|
92
92
|
return Promise.reject(err);
|
|
93
93
|
},
|
|
94
|
-
throw(error) {
|
|
94
|
+
throw(error: Error) {
|
|
95
95
|
return Promise.reject(error);
|
|
96
96
|
},
|
|
97
97
|
[$$asyncIterator]() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/callbackToAsyncIterator.js"],"names":["defaultOnError","err","callbackToAsyncIterator","listener","options","onError","buffering","onClose","pullQueue","pushQueue","listening","listenerReturnValue","pushValue","value","length","shift","done","push","pullValue","Promise","resolve","emptyQueue","forEach","undefined","then","a","catch","next","return","throw","error","reject","$$asyncIterator"],"mappings":";;;;;;;AAMA;;AALA;AACA;AACA;AACA;AACA;AAGA,MAAMA,cAAc,GAAIC,GAAD,IAAgB;AACrC,QAAMA,GAAN;AACD,CAFD;;AAIe,SAASC,uBAAT,CAIbC,QAJa,EAKbC,OAIC,GAAG,EATS,EAUb;AACA,QAAM;AAAEC,IAAAA,OAAO,GAAGL,cAAZ;AAA4BM,IAAAA,SAAS,GAAG,IAAxC;AAA8CC,IAAAA;AAA9C,MAA0DH,OAAhE;AACA,MAAII,SAAS,GAAG,EAAhB;AACA,MAAIC,SAAS,GAAG,EAAhB;AACA,MAAIC,SAAS,GAAG,IAAhB;AACA,MAAIC,mBAAJ;;AAEA,WAASC,SAAT,CAAmBC,KAAnB,EAA0B;AACxB,QAAIL,SAAS,CAACM,MAAV,KAAqB,CAAzB,EAA4B;AAC1BN,MAAAA,SAAS,CAACO,KAAV,GAAkB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AKU,MAAL,EAAjC;AACD,OAHI;;AAILA,MAAAA,MAAM,GAAwD;AAC5DP,QAAAA,UAAU;AACV,eAAOF,OAAO,CAACC,OAAR,CAAgB;AAAEP,UAAAA,KAAK,EAAEU,SAAT;AAAoBP,UAAAA,IAAI,EAAE;AAA1B,SAAhB,CAAP;AACD,OAPI;;AAQLa,MAAAA,KAAK,CAACC,KAAD,
|
|
1
|
+
{"version":3,"sources":["../src/callbackToAsyncIterator.js"],"names":["defaultOnError","err","callbackToAsyncIterator","listener","options","onError","buffering","onClose","pullQueue","pushQueue","listening","listenerReturnValue","pushValue","value","length","shift","done","push","pullValue","Promise","resolve","emptyQueue","forEach","undefined","then","a","catch","next","return","throw","error","reject","$$asyncIterator"],"mappings":";;;;;;;AAMA;;AALA;AACA;AACA;AACA;AACA;AAGA,MAAMA,cAAc,GAAIC,GAAD,IAAgB;AACrC,QAAMA,GAAN;AACD,CAFD;;AAIe,SAASC,uBAAT,CAIbC,QAJa,EAKbC,OAIC,GAAG,EATS,EAUb;AACA,QAAM;AAAEC,IAAAA,OAAO,GAAGL,cAAZ;AAA4BM,IAAAA,SAAS,GAAG,IAAxC;AAA8CC,IAAAA;AAA9C,MAA0DH,OAAhE;AACA,MAAII,SAAS,GAAG,EAAhB;AACA,MAAIC,SAAS,GAAG,EAAhB;AACA,MAAIC,SAAS,GAAG,IAAhB;AACA,MAAIC,mBAAJ;;AAEA,WAASC,SAAT,CAAmBC,KAAnB,EAA0B;AACxB,QAAIL,SAAS,CAACM,MAAV,KAAqB,CAAzB,EAA4B;AAC1BN,MAAAA,SAAS,CAACO,KAAV,GAAkB;AAAEF,QAAAA,KAAF;AAASG,QAAAA,IAAI,EAAE;AAAf,OAAlB;AACD,KAFD,MAEO,IAAIV,SAAS,KAAK,IAAlB,EAAwB;AAC7BG,MAAAA,SAAS,CAACQ,IAAV,CAAeJ,KAAf;AACD;AACF;;AAED,WAASK,SAAT,GAAqB;AACnB,WAAO,IAAIC,OAAJ,CAAYC,O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CAACC,KAAD,EAAe;AAClBT,QAAAA,UAAU;AACVhB,QAAAA,OAAO,CAACyB,KAAD,CAAP;AACA,eAAOX,OAAO,CAACY,MAAR,CAAeD,KAAf,CAAP;AACD,OAZI;;AAaL,OAACE,wBAAD,IAAoB;AAClB,eAAO,IAAP;AACD;;AAfI,KAAP;AAiBD,GA3BD,CA2BE,OAAO/B,GAAP,EAAY;AACZI,IAAAA,OAAO,CAACJ,GAAD,CAAP;AACA,WAAO;AACL0B,MAAAA,IAAI,GAAG;AACL,eAAOR,OAAO,CAACY,MAAR,CAAe9B,GAAf,CAAP;AACD,OAHI;;AAIL2B,MAAAA,MAAM,GAAG;AACP,eAAOT,OAAO,CAACY,MAAR,CAAe9B,GAAf,CAAP;AACD,OANI;;AAOL4B,MAAAA,KAAK,CAACC,KAAD,EAAe;AAClB,eAAOX,OAAO,CAACY,MAAR,CAAeD,KAAf,CAAP;AACD,OATI;;AAUL,OAACE,wBAAD,IAAoB;AAClB,eAAO,IAAP;AACD;;AAZI,KAAP;AAcD;AACF","sourcesContent":["// @flow\n/* eslint-disable flowtype/no-weak-types */\n// Turn a callback-based listener into an async iterator\n// From https://raw.githubusercontent.com/withspectrum/callback-to-async-iterator/master/src/index.js\n// License MIT (Copyright (c) 2017 Maximilian Stoiber)\n// Based on https://github.com/apollographql/graphql-subscriptions/blob/master/src/event-emitter-to-async-iterator.ts\nimport { $$asyncIterator } from \"iterall\";\n\nconst defaultOnError = (err: Error) => {\n throw err;\n};\n\nexport default function callbackToAsyncIterator<\n CallbackInput: any,\n ReturnVal: any\n>(\n listener: ((arg: CallbackInput) => any) => ?ReturnVal | Promise<?ReturnVal>,\n options?: {\n onError?: (err: Error) => void,\n onClose?: (arg?: ?ReturnVal) => void,\n buffering?: boolean,\n } = {}\n) {\n const { onError = defaultOnError, buffering = true, onClose } = options;\n let pullQueue = [];\n let pushQueue = [];\n let listening = true;\n let listenerReturnValue;\n\n function pushValue(value) {\n if (pullQueue.length !== 0) {\n pullQueue.shift()({ value, done: false });\n } else if (buffering === true) {\n pushQueue.push(value);\n }\n }\n\n function pullValue() {\n return new Promise(resolve => {\n if (pushQueue.length !== 0) {\n resolve({ value: pushQueue.shift(), done: false });\n } else {\n pullQueue.push(resolve);\n }\n });\n }\n\n function emptyQueue() {\n if (listening) {\n listening = false;\n pullQueue.forEach(resolve => resolve({ value: undefined, done: true }));\n pullQueue = [];\n pushQueue = [];\n onClose && onClose(listenerReturnValue);\n }\n }\n\n try {\n // Start listener\n Promise.resolve(listener(value => pushValue(value)))\n .then(a => {\n listenerReturnValue = a;\n })\n .catch(err => {\n onError(err);\n });\n\n return {\n next(): Promise<{ value?: CallbackInput, done: boolean }> {\n return listening ? pullValue() : this.return();\n },\n return(): Promise<{ value: typeof undefined, done: boolean }> {\n emptyQueue();\n return Promise.resolve({ value: undefined, done: true });\n },\n throw(error: Error) {\n emptyQueue();\n onError(error);\n return Promise.reject(error);\n },\n [$$asyncIterator]() {\n return this;\n },\n };\n } catch (err) {\n onError(err);\n return {\n next() {\n return Promise.reject(err);\n },\n return() {\n return Promise.reject(err);\n },\n throw(error: Error) {\n return Promise.reject(error);\n },\n [$$asyncIterator]() {\n return this;\n },\n };\n }\n}\n"],"file":"callbackToAsyncIterator.js"}
|
package/node8plus/extend.js
CHANGED
|
@@ -18,7 +18,6 @@ function indent(text) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function extend(base, extra, hint) {
|
|
21
|
-
// $FlowFixMe
|
|
22
21
|
const hints = base[$$hints] || {};
|
|
23
22
|
const keysB = Object.keys(extra);
|
|
24
23
|
const extraHints = extra[$$hints] || {};
|
|
@@ -28,7 +27,6 @@ function extend(base, extra, hint) {
|
|
|
28
27
|
const hintB = extraHints[key] || hint;
|
|
29
28
|
|
|
30
29
|
if (key in base && base[key] !== newValue) {
|
|
31
|
-
// $FlowFixMe
|
|
32
30
|
const hintA = hints[key];
|
|
33
31
|
const firstEntityDetails = !hintA ? "We don't have any information about the first entity." : `The first entity was:\n\n${indent(_chalk.default.magenta(hintA))}`;
|
|
34
32
|
const secondEntityDetails = !hintB ? "We don't have any information about the second entity." : `The second entity was:\n\n${indent(_chalk.default.yellow(hintB))}`;
|
|
@@ -41,7 +39,7 @@ function extend(base, extra, hint) {
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
return Object.assign(base, extra, {
|
|
44
|
-
// $FlowFixMe
|
|
42
|
+
// $FlowFixMe: symbols
|
|
45
43
|
[$$hints]: hints
|
|
46
44
|
});
|
|
47
45
|
}
|
package/node8plus/extend.js.flow
CHANGED
|
@@ -15,7 +15,6 @@ export default function extend<Obj1: *, Obj2: *>(
|
|
|
15
15
|
extra: Obj2,
|
|
16
16
|
hint?: string
|
|
17
17
|
): Obj1 & Obj2 {
|
|
18
|
-
// $FlowFixMe
|
|
19
18
|
const hints = base[$$hints] || {};
|
|
20
19
|
|
|
21
20
|
const keysB = Object.keys(extra);
|
|
@@ -24,7 +23,6 @@ export default function extend<Obj1: *, Obj2: *>(
|
|
|
24
23
|
const newValue = extra[key];
|
|
25
24
|
const hintB = extraHints[key] || hint;
|
|
26
25
|
if (key in base && base[key] !== newValue) {
|
|
27
|
-
// $FlowFixMe
|
|
28
26
|
const hintA: ?string = hints[key];
|
|
29
27
|
const firstEntityDetails = !hintA
|
|
30
28
|
? "We don't have any information about the first entity."
|
|
@@ -43,7 +41,7 @@ export default function extend<Obj1: *, Obj2: *>(
|
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
return Object.assign(base, extra, {
|
|
46
|
-
// $FlowFixMe
|
|
44
|
+
// $FlowFixMe: symbols
|
|
47
45
|
[$$hints]: hints,
|
|
48
46
|
});
|
|
49
47
|
}
|
package/node8plus/extend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/extend.js"],"names":["INDENT","$$hints","Symbol","indent","text","replace","extend","base","extra","hint","hints","keysB","Object","keys","extraHints","key","newValue","hintB","hintA","firstEntityDetails","chalk","magenta","secondEntityDetails","yellow","Error","bold","assign"],"mappings":";;;;;;;;AACA;;;;AAEA,MAAMA,MAAM,GAAG,IAAf;AACA,MAAMC,OAAO,GAAGC,MAAM,CAAC,OAAD,CAAtB;;AAEO,SAASC,MAAT,CAAgBC,IAAhB,EAA8B;AACnC,SACEJ,MAAM,GAAGI,IAAI,CAACC,OAAL,CAAa,KAAb,EAAoB,OAAOL,MAA3B,EAAmCK,OAAnC,CAA2C,eAA3C,EAA4D,IAA5D,CADX;AAGD;;AAEc,SAASC,MAAT,CACbC,IADa,EAEbC,KAFa,EAGbC,IAHa,EAIA;AACb
|
|
1
|
+
{"version":3,"sources":["../src/extend.js"],"names":["INDENT","$$hints","Symbol","indent","text","replace","extend","base","extra","hint","hints","keysB","Object","keys","extraHints","key","newValue","hintB","hintA","firstEntityDetails","chalk","magenta","secondEntityDetails","yellow","Error","bold","assign"],"mappings":";;;;;;;;AACA;;;;AAEA,MAAMA,MAAM,GAAG,IAAf;AACA,MAAMC,OAAO,GAAGC,MAAM,CAAC,OAAD,CAAtB;;AAEO,SAASC,MAAT,CAAgBC,IAAhB,EAA8B;AACnC,SACEJ,MAAM,GAAGI,IAAI,CAACC,OAAL,CAAa,KAAb,EAAoB,OAAOL,MAA3B,EAAmCK,OAAnC,CAA2C,eAA3C,EAA4D,IAA5D,CADX;AAGD;;AAEc,SAASC,MAAT,CACbC,IADa,EAEbC,KAFa,EAGbC,IAHa,EAIA;AACb,QAAMC,KAAK,GAAGH,IAAI,CAACN,OAAD,CAAJ,IAAiB,EAA/B;AAEA,QAAMU,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAYL,KAAZ,CAAd;AACA,QAAMM,UAAU,GAAGN,KAAK,CAACP,OAAD,CAAL,IAAkB,EAArC;;AACA,OAAK,MAAMc,GAAX,IAAkBJ,KAAlB,EAAyB;AACvB,UAAMK,QAAQ,GAAGR,KAAK,CAACO,GAAD,CAAtB;AACA,UAAME,KAAK,GAAGH,UAAU,CAACC,GAAD,CAAV,IAAmBN,IAAjC;;AACA,QAAIM,GAAG,IAAIR,IAAP,IAAeA,IAAI,CAACQ,GAAD,CAAJ,KAAcC,QAAjC,EAA2C;AACzC,YAAME,KAAc,GAAGR,KAAK,CAACK,GAAD,CAA5B;AACA,YAAMI,kBAAkB,GAAG,CAACD,KAAD,GACvB,uDADuB,GAEtB,4BAA2Bf,MAAM,CAACiB,eAAMC,OAAN,CAAcH,KAAd,CAAD,CAAuB,EAF7D;AAGA,YAAMI,mBAAmB,GAAG,CAACL,KAAD,GACxB,wDADwB,GAEvB,6BAA4Bd,MAAM,CAACiB,eAAMG,MAAN,CAAaN,KAAb,CAAD,CAAsB,EAF7D;AAGA,YAAM,IAAIO,KAAJ,CACH,oFAAmFJ,eAAMK,IAAN,CAClFV,GADkF,CAElF,SAAQZ,MAAM,CAACgB,kBAAD,CAAqB,OAAMhB,MAAM,CAACmB,mBAAD,CAAsB,EAHnE,CAAN;AAKD;;AACD,QAAIL,KAAJ,EAAW;AACTP,MAAAA,KAAK,CAACK,GAAD,CAAL,GAAaE,KAAb;AACD;AACF;;AACD,SAAOL,MAAM,CAACc,MAAP,CAAcnB,IAAd,EAAoBC,KAApB,EAA2B;AAChC;AACA,KAACP,OAAD,GAAWS;AAFqB,GAA3B,CAAP;AAID","sourcesContent":["// @flow\nimport chalk from \"chalk\";\n\nconst INDENT = \" \";\nconst $$hints = Symbol(\"hints\");\n\nexport function indent(text: string) {\n return (\n INDENT + text.replace(/\\n/g, \"\\n\" + INDENT).replace(/\\n +(?=\\n|$)/g, \"\\n\")\n );\n}\n\nexport default function extend<Obj1: *, Obj2: *>(\n base: Obj1,\n extra: Obj2,\n hint?: string\n): Obj1 & Obj2 {\n const hints = base[$$hints] || {};\n\n const keysB = Object.keys(extra);\n const extraHints = extra[$$hints] || {};\n for (const key of keysB) {\n const newValue = extra[key];\n const hintB = extraHints[key] || hint;\n if (key in base && base[key] !== newValue) {\n const hintA: ?string = hints[key];\n const firstEntityDetails = !hintA\n ? \"We don't have any information about the first entity.\"\n : `The first entity was:\\n\\n${indent(chalk.magenta(hintA))}`;\n const secondEntityDetails = !hintB\n ? \"We don't have any information about the second entity.\"\n : `The second entity was:\\n\\n${indent(chalk.yellow(hintB))}`;\n throw new Error(\n `A naming conflict has occurred - two entities have tried to define the same key '${chalk.bold(\n key\n )}'.\\n\\n${indent(firstEntityDetails)}\\n\\n${indent(secondEntityDetails)}`\n );\n }\n if (hintB) {\n hints[key] = hintB;\n }\n }\n return Object.assign(base, extra, {\n // $FlowFixMe: symbols\n [$$hints]: hints,\n });\n}\n"],"file":"extend.js"}
|
package/node8plus/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { ResolveTree } from "graphql-parse-resolve-info";
|
|
|
3
3
|
|
|
4
4
|
type CaseChangeFunction = (str: string) => string;
|
|
5
5
|
export const constantCaseAll: CaseChangeFunction;
|
|
6
|
-
export const formatInsideUnderscores: (
|
|
6
|
+
export const formatInsideUnderscores: (
|
|
7
7
|
fn: CaseChangeFunction
|
|
8
|
-
) => CaseChangeFunction
|
|
8
|
+
) => CaseChangeFunction;
|
|
9
9
|
export const upperFirst: CaseChangeFunction;
|
|
10
10
|
export const camelCase: CaseChangeFunction;
|
|
11
11
|
export const constantCase: CaseChangeFunction;
|
|
@@ -35,12 +35,7 @@ export {
|
|
|
35
35
|
Context,
|
|
36
36
|
Hook,
|
|
37
37
|
} from "./SchemaBuilder";
|
|
38
|
-
export {
|
|
39
|
-
LiveSource,
|
|
40
|
-
LiveProvider,
|
|
41
|
-
LiveMonitor,
|
|
42
|
-
LiveCoordinator,
|
|
43
|
-
} from "./Live";
|
|
38
|
+
export { LiveSource, LiveProvider, LiveMonitor, LiveCoordinator } from "./Live";
|
|
44
39
|
export { SchemaBuilder };
|
|
45
40
|
|
|
46
41
|
export const getBuilder: (
|
package/node8plus/index.js
CHANGED
|
@@ -159,7 +159,8 @@ const getBuilder = async (plugins, options = {}) => {
|
|
|
159
159
|
|
|
160
160
|
if (typeof plugin !== "function") {
|
|
161
161
|
throw new Error(`Expected a list of plugin functions, instead list contained a non-function at index ${i}: ${_util.default.inspect(plugin)}`);
|
|
162
|
-
}
|
|
162
|
+
} // $FlowFixMe: displayName
|
|
163
|
+
|
|
163
164
|
|
|
164
165
|
builder._setPluginName(plugin.displayName || plugin.name);
|
|
165
166
|
|
package/node8plus/index.js.flow
CHANGED
package/node8plus/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["getBuilder","plugins","options","builder","SchemaBuilder","i","l","length","plugin","Error","util","inspect","_setPluginName","displayName","name","buildSchema","defaultPlugins","SwallowErrorsPlugin","StandardTypesPlugin","NodePlugin","QueryPlugin","MutationPlugin","SubscriptionPlugin","ClientMutationIdDescriptionPlugin","MutationPayloadQueryPlugin","AddQueriesToSubscriptionsPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;AAWA;;AAKA;;AAyBA;;;;AAEO,MAAMA,UAAU,GAAG,OACxBC,OADwB,EAExBC,OAAgB,GAAG,EAFK,KAGG;AAC3B,QAAMC,OAAO,GAAG,IAAIC,sBAAJ,CAAkBF,OAAlB,CAAhB;;AACA,OAAK,IAAIG,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGL,OAAO,CAACM,MAA5B,EAAoCF,CAAC,GAAGC,CAAxC,EAA2CD,CAAC,EAA5C,EAAgD;AAC9C,UAAMG,MAAM,GAAGP,OAAO,CAACI,CAAD,CAAtB;;AACA,QAAI,OAAOG,MAAP,KAAkB,UAAtB,EAAkC;AAChC,YAAM,IAAIC,KAAJ,CACH,uFAAsFJ,CAAE,KAAIK,cAAKC,OAAL,CAC3FH,MAD2F,CAE3F,EAHE,CAAN;AAKD
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["getBuilder","plugins","options","builder","SchemaBuilder","i","l","length","plugin","Error","util","inspect","_setPluginName","displayName","name","buildSchema","defaultPlugins","SwallowErrorsPlugin","StandardTypesPlugin","NodePlugin","QueryPlugin","MutationPlugin","SubscriptionPlugin","ClientMutationIdDescriptionPlugin","MutationPayloadQueryPlugin","AddQueriesToSubscriptionsPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;AAWA;;AAKA;;AAyBA;;;;AAEO,MAAMA,UAAU,GAAG,OACxBC,OADwB,EAExBC,OAAgB,GAAG,EAFK,KAGG;AAC3B,QAAMC,OAAO,GAAG,IAAIC,sBAAJ,CAAkBF,OAAlB,CAAhB;;AACA,OAAK,IAAIG,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGL,OAAO,CAACM,MAA5B,EAAoCF,CAAC,GAAGC,CAAxC,EAA2CD,CAAC,EAA5C,EAAgD;AAC9C,UAAMG,MAAM,GAAGP,OAAO,CAACI,CAAD,CAAtB;;AACA,QAAI,OAAOG,MAAP,KAAkB,UAAtB,EAAkC;AAChC,YAAM,IAAIC,KAAJ,CACH,uFAAsFJ,CAAE,KAAIK,cAAKC,OAAL,CAC3FH,MAD2F,CAE3F,EAHE,CAAN;AAKD,KAR6C,CAS9C;;;AACAL,IAAAA,OAAO,CAACS,cAAR,CAAuBJ,MAAM,CAACK,WAAP,IAAsBL,MAAM,CAACM,IAApD;;AACA,UAAMN,MAAM,CAACL,OAAD,EAAUD,OAAV,CAAZ;;AACAC,IAAAA,OAAO,CAACS,cAAR,CAAuB,IAAvB;AACD;;AACD,SAAOT,OAAP;AACD,CApBM;;;;AAsBA,MAAMY,WAAW,GAAG,OACzBd,OADyB,EAEzBC,OAAgB,GAAG,EAFM,KAGE;AAC3B,QAAMC,OAAsB,GAAG,MAAMH,UAAU,CAACC,OAAD,EAAUC,OAAV,CAA/C;AACA,SAAOC,OAAO,CAACY,WAAR,EAAP;AACD,CANM;;;AAQA,MAAMC,cAA6B,GAAG,CAC3CC,4BAD2C,EAE3CC,4BAF2C,EAG3CC,mBAH2C,EAI3CC,oBAJ2C,EAK3CC,uBAL2C,EAM3CC,2BAN2C,EAO3CC,0CAP2C,EAQ3CC,mCAR2C,EAS3CC,wCAT2C,CAAtC","sourcesContent":["// @flow\n\nimport util from \"util\";\nimport SchemaBuilder from \"./SchemaBuilder\";\nimport {\n SwallowErrorsPlugin,\n StandardTypesPlugin,\n NodePlugin,\n QueryPlugin,\n MutationPlugin,\n SubscriptionPlugin,\n ClientMutationIdDescriptionPlugin,\n MutationPayloadQueryPlugin,\n AddQueriesToSubscriptionsPlugin,\n} from \"./plugins\";\nimport resolveNode from \"./resolveNode\";\nimport type { GraphQLSchema } from \"graphql\";\n\nimport type { Plugin, Options } from \"./SchemaBuilder\";\n\nexport {\n constantCaseAll,\n formatInsideUnderscores,\n upperFirst,\n camelCase,\n constantCase,\n upperCamelCase,\n pluralize,\n singularize,\n} from \"./utils\";\n\nexport type { SchemaBuilder };\n\nexport type {\n Plugin,\n Options,\n Build,\n BuildExtensionQuery,\n Scope,\n Context,\n Hook,\n WatchUnwatch,\n SchemaListener,\n} from \"./SchemaBuilder\";\n\nexport { LiveSource, LiveProvider, LiveMonitor, LiveCoordinator } from \"./Live\";\n\nexport const getBuilder = async (\n plugins: Array<Plugin>,\n options: Options = {}\n): Promise<SchemaBuilder> => {\n const builder = new SchemaBuilder(options);\n for (let i = 0, l = plugins.length; i < l; i++) {\n const plugin = plugins[i];\n if (typeof plugin !== \"function\") {\n throw new Error(\n `Expected a list of plugin functions, instead list contained a non-function at index ${i}: ${util.inspect(\n plugin\n )}`\n );\n }\n // $FlowFixMe: displayName\n builder._setPluginName(plugin.displayName || plugin.name);\n await plugin(builder, options);\n builder._setPluginName(null);\n }\n return builder;\n};\n\nexport const buildSchema = async (\n plugins: Array<Plugin>,\n options: Options = {}\n): Promise<GraphQLSchema> => {\n const builder: SchemaBuilder = await getBuilder(plugins, options);\n return builder.buildSchema();\n};\n\nexport const defaultPlugins: Array<Plugin> = [\n SwallowErrorsPlugin,\n StandardTypesPlugin,\n NodePlugin,\n QueryPlugin,\n MutationPlugin,\n SubscriptionPlugin,\n ClientMutationIdDescriptionPlugin,\n MutationPayloadQueryPlugin,\n AddQueriesToSubscriptionsPlugin,\n];\n\nexport {\n SwallowErrorsPlugin,\n StandardTypesPlugin,\n NodePlugin,\n QueryPlugin,\n MutationPlugin,\n SubscriptionPlugin,\n ClientMutationIdDescriptionPlugin,\n MutationPayloadQueryPlugin,\n AddQueriesToSubscriptionsPlugin,\n // resolveNode: EXPERIMENTAL, API might change!\n resolveNode,\n};\n"],"file":"index.js"}
|
|
@@ -35,7 +35,9 @@ var _package = require("../package.json");
|
|
|
35
35
|
|
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
37
|
|
|
38
|
-
function
|
|
38
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
39
|
+
|
|
40
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
41
|
|
|
40
42
|
let recurseDataGeneratorsForFieldWarned = false;
|
|
41
43
|
|
|
@@ -160,6 +162,7 @@ function ensureArray(val) {
|
|
|
160
162
|
if (val == null) {
|
|
161
163
|
return;
|
|
162
164
|
} else if (Array.isArray(val)) {
|
|
165
|
+
// $FlowFixMe
|
|
163
166
|
return val;
|
|
164
167
|
} else {
|
|
165
168
|
return [val];
|
|
@@ -167,10 +170,11 @@ function ensureArray(val) {
|
|
|
167
170
|
} // eslint-disable-next-line no-unused-vars
|
|
168
171
|
|
|
169
172
|
|
|
170
|
-
let ensureName =
|
|
173
|
+
let ensureName = _fn => {};
|
|
171
174
|
|
|
172
175
|
if (["development", "test"].indexOf(process.env.NODE_ENV) >= 0) {
|
|
173
176
|
ensureName = fn => {
|
|
177
|
+
// $FlowFixMe: displayName
|
|
174
178
|
if (isDev && !fn.displayName && !fn.name && debug.enabled) {
|
|
175
179
|
// eslint-disable-next-line no-console
|
|
176
180
|
console.trace("WARNING: you've added a function with no name as an argDataGenerator, doing so may make debugging more challenging");
|
|
@@ -291,7 +295,9 @@ function makeNewBuild(builder) {
|
|
|
291
295
|
});
|
|
292
296
|
} else if (Type === GraphQLObjectType) {
|
|
293
297
|
const addDataGeneratorForField = (fieldName, fn) => {
|
|
294
|
-
|
|
298
|
+
// $FlowFixMe: displayName
|
|
299
|
+
fn.displayName = // $FlowFixMe: displayName
|
|
300
|
+
fn.displayName || `${getNameFromType(Self)}:${fieldName}[${fn.name || "anonymous"}]`;
|
|
295
301
|
fieldDataGeneratorsByFieldName[fieldName] = fieldDataGeneratorsByFieldName[fieldName] || [];
|
|
296
302
|
fieldDataGeneratorsByFieldName[fieldName].push(fn);
|
|
297
303
|
};
|
|
@@ -405,10 +411,10 @@ function makeNewBuild(builder) {
|
|
|
405
411
|
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 `{}`.");
|
|
406
412
|
}
|
|
407
413
|
|
|
408
|
-
|
|
414
|
+
const argDataGenerators = [];
|
|
409
415
|
fieldArgDataGeneratorsByFieldName[fieldName] = argDataGenerators;
|
|
410
416
|
let newSpec = spec;
|
|
411
|
-
|
|
417
|
+
const context = { ...commonContext,
|
|
412
418
|
Self,
|
|
413
419
|
|
|
414
420
|
addDataGenerator(fn) {
|
|
@@ -532,7 +538,7 @@ function makeNewBuild(builder) {
|
|
|
532
538
|
throw new Error("It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is current necessary.");
|
|
533
539
|
}
|
|
534
540
|
|
|
535
|
-
|
|
541
|
+
const context = { ...commonContext,
|
|
536
542
|
Self,
|
|
537
543
|
scope: (0, _extend.default)((0, _extend.default)({ ...scope
|
|
538
544
|
}, {
|
|
@@ -172,7 +172,9 @@ const mergeData = (
|
|
|
172
172
|
ReturnType,
|
|
173
173
|
arg
|
|
174
174
|
) => {
|
|
175
|
-
const results: ?Array<MetaData> = ensureArray(
|
|
175
|
+
const results: ?Array<MetaData> = ensureArray<MetaData>(
|
|
176
|
+
gen(arg, ReturnType, data)
|
|
177
|
+
);
|
|
176
178
|
if (!results) {
|
|
177
179
|
return;
|
|
178
180
|
}
|
|
@@ -187,7 +189,7 @@ const mergeData = (
|
|
|
187
189
|
const k = keys[i];
|
|
188
190
|
data[k] = data[k] || [];
|
|
189
191
|
const value: mixed = result[k];
|
|
190
|
-
const newData: ?Array<mixed> = ensureArray(value);
|
|
192
|
+
const newData: ?Array<mixed> = ensureArray<mixed>(value);
|
|
191
193
|
if (newData) {
|
|
192
194
|
data[k].push(...newData);
|
|
193
195
|
}
|
|
@@ -204,20 +206,22 @@ const knownTypes = [
|
|
|
204
206
|
];
|
|
205
207
|
const knownTypeNames = knownTypes.map(k => k.name);
|
|
206
208
|
|
|
207
|
-
function ensureArray<T>(val:
|
|
209
|
+
function ensureArray<T>(val: null | T | Array<T>): void | Array<T> {
|
|
208
210
|
if (val == null) {
|
|
209
211
|
return;
|
|
210
212
|
} else if (Array.isArray(val)) {
|
|
211
|
-
|
|
213
|
+
// $FlowFixMe
|
|
214
|
+
return (val: Array<T>);
|
|
212
215
|
} else {
|
|
213
|
-
return [val];
|
|
216
|
+
return ([val]: Array<T>);
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
|
|
217
220
|
// eslint-disable-next-line no-unused-vars
|
|
218
|
-
let ensureName =
|
|
221
|
+
let ensureName = _fn => {};
|
|
219
222
|
if (["development", "test"].indexOf(process.env.NODE_ENV) >= 0) {
|
|
220
223
|
ensureName = fn => {
|
|
224
|
+
// $FlowFixMe: displayName
|
|
221
225
|
if (isDev && !fn.displayName && !fn.name && debug.enabled) {
|
|
222
226
|
// eslint-disable-next-line no-console
|
|
223
227
|
console.trace(
|
|
@@ -336,9 +340,7 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
336
340
|
if (!inScope) {
|
|
337
341
|
// eslint-disable-next-line no-console
|
|
338
342
|
console.warn(
|
|
339
|
-
`No scope was provided to new ${Type.name}[name=${
|
|
340
|
-
spec.name
|
|
341
|
-
}], 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.`
|
|
343
|
+
`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.`
|
|
342
344
|
);
|
|
343
345
|
}
|
|
344
346
|
if (!Type) {
|
|
@@ -357,9 +359,7 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
357
359
|
knownTypeNames.indexOf(Type.name) >= 0
|
|
358
360
|
) {
|
|
359
361
|
throw new Error(
|
|
360
|
-
`GraphQL conflict for '${
|
|
361
|
-
Type.name
|
|
362
|
-
}' detected! Multiple versions of graphql exist in your node_modules?`
|
|
362
|
+
`GraphQL conflict for '${Type.name}' detected! Multiple versions of graphql exist in your node_modules?`
|
|
363
363
|
);
|
|
364
364
|
}
|
|
365
365
|
if (Type === GraphQLSchema) {
|
|
@@ -372,7 +372,9 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
372
372
|
fieldName,
|
|
373
373
|
fn: DataGeneratorFunction
|
|
374
374
|
) => {
|
|
375
|
+
// $FlowFixMe: displayName
|
|
375
376
|
fn.displayName =
|
|
377
|
+
// $FlowFixMe: displayName
|
|
376
378
|
fn.displayName ||
|
|
377
379
|
`${getNameFromType(Self)}:${fieldName}[${fn.name || "anonymous"}]`;
|
|
378
380
|
fieldDataGeneratorsByFieldName[fieldName] =
|
|
@@ -532,13 +534,13 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
532
534
|
);
|
|
533
535
|
}
|
|
534
536
|
|
|
535
|
-
|
|
537
|
+
const argDataGenerators = [];
|
|
536
538
|
fieldArgDataGeneratorsByFieldName[
|
|
537
539
|
fieldName
|
|
538
540
|
] = argDataGenerators;
|
|
539
541
|
|
|
540
542
|
let newSpec = spec;
|
|
541
|
-
|
|
543
|
+
const context = {
|
|
542
544
|
...commonContext,
|
|
543
545
|
Self,
|
|
544
546
|
addDataGenerator(fn) {
|
|
@@ -626,9 +628,7 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
626
628
|
`Within context for GraphQLObjectType '${rawSpec.name}'`
|
|
627
629
|
),
|
|
628
630
|
fieldScope,
|
|
629
|
-
`Extending scope for field '${fieldName}' within context for GraphQLObjectType '${
|
|
630
|
-
rawSpec.name
|
|
631
|
-
}'`
|
|
631
|
+
`Extending scope for field '${fieldName}' within context for GraphQLObjectType '${rawSpec.name}'`
|
|
632
632
|
),
|
|
633
633
|
};
|
|
634
634
|
if (typeof newSpec === "function") {
|
|
@@ -724,7 +724,7 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
724
724
|
"It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is current necessary."
|
|
725
725
|
);
|
|
726
726
|
}
|
|
727
|
-
|
|
727
|
+
const context = {
|
|
728
728
|
...commonContext,
|
|
729
729
|
Self,
|
|
730
730
|
scope: extend(
|
|
@@ -733,14 +733,10 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
733
733
|
{
|
|
734
734
|
fieldName,
|
|
735
735
|
},
|
|
736
|
-
`Within context for GraphQLInputObjectType '${
|
|
737
|
-
rawSpec.name
|
|
738
|
-
}'`
|
|
736
|
+
`Within context for GraphQLInputObjectType '${rawSpec.name}'`
|
|
739
737
|
),
|
|
740
738
|
fieldScope,
|
|
741
|
-
`Extending scope for field '${fieldName}' within context for GraphQLInputObjectType '${
|
|
742
|
-
rawSpec.name
|
|
743
|
-
}'`
|
|
739
|
+
`Extending scope for field '${fieldName}' within context for GraphQLInputObjectType '${rawSpec.name}'`
|
|
744
740
|
),
|
|
745
741
|
};
|
|
746
742
|
let newSpec = spec;
|
|
@@ -907,9 +903,7 @@ export default function makeNewBuild(builder: SchemaBuilder): { ...Build } {
|
|
|
907
903
|
Self,
|
|
908
904
|
scope.__origin ||
|
|
909
905
|
(this
|
|
910
|
-
? `'newWithHooks' call during hook '${
|
|
911
|
-
this.status.currentHookName
|
|
912
|
-
}'`
|
|
906
|
+
? `'newWithHooks' call during hook '${this.status.currentHookName}'`
|
|
913
907
|
: null)
|
|
914
908
|
);
|
|
915
909
|
}
|