Comparing version 0.12.0-beta.13 to 0.12.0-beta.14
@@ -5,2 +5,6 @@ # Changelog | ||
#### beta.13 | ||
- fix(typegen): explicitly await removeFile before write (#254) | ||
#### beta.12 | ||
@@ -7,0 +11,0 @@ |
@@ -19,3 +19,5 @@ import { GraphQLEnumType, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLFieldResolver, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLOutputType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType, GraphQLField } from "graphql"; | ||
import { DynamicOutputPropertyDef } from "./dynamicProperty"; | ||
import * as Plugins from "./plugins"; | ||
export declare type Maybe<T> = T | null; | ||
export declare type NexusAcceptedTypeDef = AllNexusNamedTypeDefs | NexusExtendInputTypeDef<string> | NexusExtendTypeDef<string> | GraphQLNamedType | DynamicInputMethodDef<string> | DynamicOutputMethodDef<string> | DynamicOutputPropertyDef<string>; | ||
declare type NexusShapedOutput = { | ||
@@ -33,2 +35,3 @@ name: string; | ||
export interface BuilderConfig { | ||
plugins?: Plugins.PluginDef[]; | ||
/** | ||
@@ -49,3 +52,3 @@ * Generated artifact settings. Set to false to disable all. | ||
* | ||
* The default path is node_modules/@types/__nexus-typegen__core/index.d.ts. | ||
* The default path is node_modules/@types/nexus-typegen/index.d.ts. | ||
* This is chosen becuase TypeScript will pick it up without | ||
@@ -167,2 +170,8 @@ * any configuration needed by you. For more details about the @types | ||
/** | ||
* Used to track all _GraphQL_ types that have been added to the builder. | ||
* This supports hasType method which permits asking the question "Will | ||
* the GraphQL schema have _this_ type (name)". | ||
*/ | ||
protected allTypeDefs: Record<string, NexusAcceptedTypeDef>; | ||
/** | ||
* Used to check for circular references. | ||
@@ -228,12 +237,10 @@ */ | ||
getConfig(): BuilderConfig; | ||
hasType: (typeName: string) => boolean; | ||
/** | ||
* Add type takes a Nexus type, or a GraphQL type and pulls | ||
* it into an internal "type registry". It also does an initial pass | ||
* on any types that are referenced on the "types" field and pulls | ||
* those in too, so you can define types anonymously, without | ||
* exporting them. | ||
* | ||
* @param typeDef | ||
* Add type takes a Nexus type, or a GraphQL type and pulls it into an | ||
* internal "type registry". It also does an initial pass on any types that | ||
* are referenced on the "types" field and pulls those in too, so you can | ||
* define types anonymously, without exporting them. | ||
*/ | ||
addType(typeDef: AllNexusNamedTypeDefs | NexusExtendInputTypeDef<string> | NexusExtendTypeDef<string> | GraphQLNamedType | DynamicInputMethodDef<string> | DynamicOutputMethodDef<string> | DynamicOutputPropertyDef<string>): void; | ||
addType: (typeDef: NexusAcceptedTypeDef) => void; | ||
walkTypes(): void; | ||
@@ -240,0 +247,0 @@ getFinalTypeMap(): BuildTypes<any>; |
@@ -15,2 +15,3 @@ "use strict"; | ||
var decorateType_1 = require("./definitions/decorateType"); | ||
var Plugins = tslib_1.__importStar(require("./plugins")); | ||
var SCALARS = { | ||
@@ -110,4 +111,11 @@ String: graphql_1.GraphQLString, | ||
function SchemaBuilder(config) { | ||
var _this = this; | ||
this.config = config; | ||
/** | ||
* Used to track all _GraphQL_ types that have been added to the builder. | ||
* This supports hasType method which permits asking the question "Will | ||
* the GraphQL schema have _this_ type (name)". | ||
*/ | ||
this.allTypeDefs = {}; | ||
/** | ||
* Used to check for circular references. | ||
@@ -171,88 +179,91 @@ */ | ||
this.finalized = false; | ||
this.nonNullDefaults = tslib_1.__assign({ input: false, output: true }, config.nonNullDefaults); | ||
} | ||
SchemaBuilder.prototype.getConfig = function () { | ||
return this.config; | ||
}; | ||
/** | ||
* Add type takes a Nexus type, or a GraphQL type and pulls | ||
* it into an internal "type registry". It also does an initial pass | ||
* on any types that are referenced on the "types" field and pulls | ||
* those in too, so you can define types anonymously, without | ||
* exporting them. | ||
* | ||
* @param typeDef | ||
*/ | ||
SchemaBuilder.prototype.addType = function (typeDef) { | ||
if (wrapping_1.isNexusDynamicInputMethod(typeDef)) { | ||
this.dynamicInputFields[typeDef.name] = typeDef; | ||
return; | ||
} | ||
if (wrapping_1.isNexusDynamicOutputMethod(typeDef)) { | ||
this.dynamicOutputFields[typeDef.name] = typeDef; | ||
return; | ||
} | ||
if (wrapping_1.isNexusDynamicOutputProperty(typeDef)) { | ||
this.dynamicOutputProperties[typeDef.name] = typeDef; | ||
return; | ||
} | ||
var existingType = this.finalTypeMap[typeDef.name] || this.pendingTypeMap[typeDef.name]; | ||
if (wrapping_1.isNexusExtendTypeDef(typeDef)) { | ||
var typeExtensions = (this.typeExtensionMap[typeDef.name] = | ||
this.typeExtensionMap[typeDef.name] || []); | ||
typeExtensions.push(typeDef.value); | ||
this.typesToWalk.push({ type: "object", value: typeDef.value }); | ||
return; | ||
} | ||
if (wrapping_1.isNexusExtendInputTypeDef(typeDef)) { | ||
var typeExtensions = (this.inputTypeExtensionMap[typeDef.name] = | ||
this.inputTypeExtensionMap[typeDef.name] || []); | ||
typeExtensions.push(typeDef.value); | ||
this.typesToWalk.push({ type: "input", value: typeDef.value }); | ||
return; | ||
} | ||
if (existingType) { | ||
// Allow importing the same exact type more than once. | ||
if (existingType === typeDef) { | ||
this.hasType = function (typeName) { | ||
return Boolean(_this.allTypeDefs[typeName]); | ||
}; | ||
/** | ||
* Add type takes a Nexus type, or a GraphQL type and pulls it into an | ||
* internal "type registry". It also does an initial pass on any types that | ||
* are referenced on the "types" field and pulls those in too, so you can | ||
* define types anonymously, without exporting them. | ||
*/ | ||
this.addType = function (typeDef) { | ||
if (wrapping_1.isNexusDynamicInputMethod(typeDef)) { | ||
_this.dynamicInputFields[typeDef.name] = typeDef; | ||
return; | ||
} | ||
throw extendError(typeDef.name); | ||
} | ||
if (wrapping_1.isNexusScalarTypeDef(typeDef) && typeDef.value.asNexusMethod) { | ||
this.dynamicInputFields[typeDef.value.asNexusMethod] = typeDef.name; | ||
this.dynamicOutputFields[typeDef.value.asNexusMethod] = typeDef.name; | ||
if (typeDef.value.rootTyping) { | ||
this.rootTypings[typeDef.name] = typeDef.value.rootTyping; | ||
if (wrapping_1.isNexusDynamicOutputMethod(typeDef)) { | ||
_this.dynamicOutputFields[typeDef.name] = typeDef; | ||
return; | ||
} | ||
} | ||
else if (graphql_1.isScalarType(typeDef)) { | ||
var scalarDef = typeDef; | ||
if (scalarDef.extensions && scalarDef.extensions.nexus) { | ||
var _a = scalarDef.extensions.nexus, asNexusMethod = _a.asNexusMethod, rootTyping = _a.rootTyping; | ||
if (asNexusMethod) { | ||
this.dynamicInputFields[asNexusMethod] = scalarDef.name; | ||
this.dynamicOutputFields[asNexusMethod] = typeDef.name; | ||
if (wrapping_1.isNexusDynamicOutputProperty(typeDef)) { | ||
_this.dynamicOutputProperties[typeDef.name] = typeDef; | ||
return; | ||
} | ||
var existingType = _this.finalTypeMap[typeDef.name] || _this.pendingTypeMap[typeDef.name]; | ||
if (wrapping_1.isNexusExtendTypeDef(typeDef)) { | ||
var typeExtensions = (_this.typeExtensionMap[typeDef.name] = | ||
_this.typeExtensionMap[typeDef.name] || []); | ||
typeExtensions.push(typeDef.value); | ||
_this.typesToWalk.push({ type: "object", value: typeDef.value }); | ||
return; | ||
} | ||
if (wrapping_1.isNexusExtendInputTypeDef(typeDef)) { | ||
var typeExtensions = (_this.inputTypeExtensionMap[typeDef.name] = | ||
_this.inputTypeExtensionMap[typeDef.name] || []); | ||
typeExtensions.push(typeDef.value); | ||
_this.typesToWalk.push({ type: "input", value: typeDef.value }); | ||
return; | ||
} | ||
if (existingType) { | ||
// Allow importing the same exact type more than once. | ||
if (existingType === typeDef) { | ||
return; | ||
} | ||
if (rootTyping) { | ||
this.rootTypings[scalarDef.name] = rootTyping; | ||
throw extendError(typeDef.name); | ||
} | ||
if (!_this.allTypeDefs[typeDef.name]) { | ||
_this.allTypeDefs[typeDef.name] = typeDef; | ||
} | ||
if (wrapping_1.isNexusScalarTypeDef(typeDef) && typeDef.value.asNexusMethod) { | ||
_this.dynamicInputFields[typeDef.value.asNexusMethod] = typeDef.name; | ||
_this.dynamicOutputFields[typeDef.value.asNexusMethod] = typeDef.name; | ||
if (typeDef.value.rootTyping) { | ||
_this.rootTypings[typeDef.name] = typeDef.value.rootTyping; | ||
} | ||
} | ||
} | ||
if (graphql_1.isNamedType(typeDef)) { | ||
this.finalTypeMap[typeDef.name] = typeDef; | ||
this.definedTypeMap[typeDef.name] = typeDef; | ||
this.typesToWalk.push({ type: "named", value: typeDef }); | ||
} | ||
else { | ||
this.pendingTypeMap[typeDef.name] = typeDef; | ||
} | ||
if (wrapping_1.isNexusInputObjectTypeDef(typeDef)) { | ||
this.typesToWalk.push({ type: "input", value: typeDef.value }); | ||
} | ||
if (wrapping_1.isNexusObjectTypeDef(typeDef)) { | ||
this.typesToWalk.push({ type: "object", value: typeDef.value }); | ||
} | ||
if (wrapping_1.isNexusInterfaceTypeDef(typeDef)) { | ||
this.typesToWalk.push({ type: "interface", value: typeDef.value }); | ||
} | ||
else if (graphql_1.isScalarType(typeDef)) { | ||
var scalarDef = typeDef; | ||
if (scalarDef.extensions && scalarDef.extensions.nexus) { | ||
var _a = scalarDef.extensions.nexus, asNexusMethod = _a.asNexusMethod, rootTyping = _a.rootTyping; | ||
if (asNexusMethod) { | ||
_this.dynamicInputFields[asNexusMethod] = scalarDef.name; | ||
_this.dynamicOutputFields[asNexusMethod] = typeDef.name; | ||
} | ||
if (rootTyping) { | ||
_this.rootTypings[scalarDef.name] = rootTyping; | ||
} | ||
} | ||
} | ||
if (graphql_1.isNamedType(typeDef)) { | ||
_this.finalTypeMap[typeDef.name] = typeDef; | ||
_this.definedTypeMap[typeDef.name] = typeDef; | ||
_this.typesToWalk.push({ type: "named", value: typeDef }); | ||
} | ||
else { | ||
_this.pendingTypeMap[typeDef.name] = typeDef; | ||
} | ||
if (wrapping_1.isNexusInputObjectTypeDef(typeDef)) { | ||
_this.typesToWalk.push({ type: "input", value: typeDef.value }); | ||
} | ||
if (wrapping_1.isNexusObjectTypeDef(typeDef)) { | ||
_this.typesToWalk.push({ type: "object", value: typeDef.value }); | ||
} | ||
if (wrapping_1.isNexusInterfaceTypeDef(typeDef)) { | ||
_this.typesToWalk.push({ type: "interface", value: typeDef.value }); | ||
} | ||
}; | ||
this.nonNullDefaults = tslib_1.__assign({ input: false, output: true }, config.nonNullDefaults); | ||
} | ||
SchemaBuilder.prototype.getConfig = function () { | ||
return this.config; | ||
}; | ||
@@ -366,3 +377,3 @@ SchemaBuilder.prototype.walkTypes = function () { | ||
addField: function (fieldDef) { return fields.push(fieldDef); }, | ||
addInterfaces: function (interfaceDefs) { return interfaces.push.apply(interfaces, interfaceDefs); }, | ||
addInterfaces: function (interfaceDefs) { return interfaces.push.apply(interfaces, tslib_1.__spread(interfaceDefs)); }, | ||
addFieldModifications: function (mods) { | ||
@@ -969,3 +980,10 @@ modifications[mods.field] = modifications[mods.field] || []; | ||
var builder = schemaBuilder || new SchemaBuilder(config); | ||
var plugins = config.plugins || []; | ||
var pluginControllers = plugins.map(function (plugin) { | ||
return Plugins.initialize(builder, plugin); | ||
}); | ||
addTypes(builder, types); | ||
pluginControllers.forEach(function (pluginController) { | ||
return pluginController.triggerOnInstall(); | ||
}); | ||
return builder.getFinalTypeMap(); | ||
@@ -972,0 +990,0 @@ } |
@@ -22,3 +22,4 @@ import { GraphQLLeafType, GraphQLCompositeType, GraphQLInputObjectType, GraphQLFieldResolver } from "graphql"; | ||
DynamicOutputMethod = "DynamicOutputMethod", | ||
DynamicOutputProperty = "DynamicOutputProperty" | ||
DynamicOutputProperty = "DynamicOutputProperty", | ||
Plugin = "Plugin" | ||
} | ||
@@ -25,0 +26,0 @@ export interface DeprecationInfo { |
@@ -20,2 +20,3 @@ "use strict"; | ||
NexusTypes["DynamicOutputProperty"] = "DynamicOutputProperty"; | ||
NexusTypes["Plugin"] = "Plugin"; | ||
})(NexusTypes = exports.NexusTypes || (exports.NexusTypes = {})); | ||
@@ -22,0 +23,0 @@ exports.NexusWrappedSymbol = Symbol.for("@nexus/wrapped"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var dynamicMethod_1 = require("../dynamicMethod"); | ||
@@ -11,3 +12,3 @@ var objectType_1 = require("../definitions/objectType"); | ||
factory: function (_a) { | ||
var t = _a.typeDef, _b = _a.args, fieldName = _b[0], config = _b[1]; | ||
var t = _a.typeDef, _b = tslib_1.__read(_a.args, 2), fieldName = _b[0], config = _b[1]; | ||
if (!config.type) { | ||
@@ -14,0 +15,0 @@ throw new Error("Missing required property \"type\" from collectionField " + fieldName); |
@@ -13,3 +13,3 @@ "use strict"; | ||
factory: function (_a) { | ||
var t = _a.typeDef, _b = _a.args, fieldName = _b[0], config = _b[1]; | ||
var t = _a.typeDef, _b = tslib_1.__read(_a.args, 2), fieldName = _b[0], config = _b[1]; | ||
if (!config.type) { | ||
@@ -16,0 +16,0 @@ throw new Error("Missing required property \"type\" from relayConnection field " + fieldName); |
@@ -0,1 +1,2 @@ | ||
export { createPlugin, PluginConfig, PluginBuilderLens, PluginOnInstallHandler, } from "./plugins"; | ||
export { buildTypes, makeSchema } from "./builder"; | ||
@@ -2,0 +3,0 @@ export { arg, booleanArg, floatArg, idArg, intArg, stringArg, } from "./definitions/args"; |
@@ -5,2 +5,4 @@ "use strict"; | ||
// All of the Public API definitions | ||
var plugins_1 = require("./plugins"); | ||
exports.createPlugin = plugins_1.createPlugin; | ||
var builder_1 = require("./builder"); | ||
@@ -7,0 +9,0 @@ exports.buildTypes = builder_1.buildTypes; |
@@ -182,3 +182,3 @@ "use strict"; | ||
.forEach(function (alias) { | ||
var _a = importsMap[alias], importPath = _a[0], glob = _a[1]; | ||
var _a = tslib_1.__read(importsMap[alias], 2), importPath = _a[0], glob = _a[1]; | ||
var safeImportPath = importPath.replace(/\\+/g, "/"); | ||
@@ -185,0 +185,0 @@ imports.push("import " + (glob ? "* as " : "") + alias + " from \"" + safeImportPath + "\""); |
@@ -67,3 +67,3 @@ "use strict"; | ||
util = require("util"); | ||
_a = [ | ||
_a = tslib_1.__read([ | ||
util.promisify(fs.readFile), | ||
@@ -73,3 +73,3 @@ util.promisify(fs.writeFile), | ||
util.promisify(fs.mkdir), | ||
], readFile = _a[0], writeFile = _a[1], removeFile = _a[2], mkdir = _a[3]; | ||
], 4), readFile = _a[0], writeFile = _a[1], removeFile = _a[2], mkdir = _a[3]; | ||
formatTypegen = null; | ||
@@ -97,3 +97,3 @@ if (typeof this.config.formatTypegen === "function") { | ||
case 4: | ||
_c = _d.sent(), toSave = _c[0], existing = _c[1]; | ||
_c = tslib_1.__read.apply(void 0, [_d.sent(), 2]), toSave = _c[0], existing = _c[1]; | ||
if (!(toSave !== existing)) return [3 /*break*/, 12]; | ||
@@ -100,0 +100,0 @@ dirPath = path_1.default.dirname(filePath); |
@@ -36,1 +36,10 @@ import { GraphQLObjectType, GraphQLInterfaceType, GraphQLSchema, GraphQLInputObjectType, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, GraphQLNamedType } from "graphql"; | ||
export declare function relativePathTo(absolutePath: string, outputPath: string): string; | ||
/** | ||
* Calculate the venn diagram between two iterables based on reference equality | ||
* checks. The returned tripple contains items thusly: | ||
* | ||
* * items only in arg 1 --> first tripple slot | ||
* * items in args 1 & 2 --> second tripple slot | ||
* * items only in arg 2 --> third tripple slot | ||
*/ | ||
export declare function venn<T>(xs: Iterable<T>, ys: Iterable<T>): [Set<T>, Set<T>, Set<T>]; |
@@ -186,2 +186,52 @@ "use strict"; | ||
exports.relativePathTo = relativePathTo; | ||
/** | ||
* Calculate the venn diagram between two iterables based on reference equality | ||
* checks. The returned tripple contains items thusly: | ||
* | ||
* * items only in arg 1 --> first tripple slot | ||
* * items in args 1 & 2 --> second tripple slot | ||
* * items only in arg 2 --> third tripple slot | ||
*/ | ||
function venn(xs, ys) { | ||
var e_1, _a, e_2, _b; | ||
var lefts = new Set(xs); | ||
var boths = new Set(); | ||
var rights = new Set(ys); | ||
try { | ||
for (var lefts_1 = tslib_1.__values(lefts), lefts_1_1 = lefts_1.next(); !lefts_1_1.done; lefts_1_1 = lefts_1.next()) { | ||
var l = lefts_1_1.value; | ||
if (rights.has(l)) { | ||
boths.add(l); | ||
lefts.delete(l); | ||
rights.delete(l); | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (lefts_1_1 && !lefts_1_1.done && (_a = lefts_1.return)) _a.call(lefts_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
try { | ||
for (var rights_1 = tslib_1.__values(rights), rights_1_1 = rights_1.next(); !rights_1_1.done; rights_1_1 = rights_1.next()) { | ||
var r = rights_1_1.value; | ||
if (lefts.has(r)) { | ||
boths.add(r); | ||
lefts.delete(r); | ||
rights.delete(r); | ||
} | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (rights_1_1 && !rights_1_1.done && (_b = rights_1.return)) _b.call(rights_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
return [lefts, boths, rights]; | ||
} | ||
exports.venn = venn; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "nexus", | ||
"version": "0.12.0-beta.13", | ||
"version": "0.12.0-beta.14", | ||
"main": "dist", | ||
@@ -14,2 +14,3 @@ "types": "dist/index.d.ts", | ||
"dev": "tsc -w", | ||
"dev:test": "jest --watch", | ||
"dev:examples": "yarn -s link-examples && tsc -w", | ||
@@ -49,2 +50,3 @@ "lint": "tslint -p tsconfig.json", | ||
"@types/prettier": "^1.15.2", | ||
"codecov": "^3.6.1", | ||
"graphql": "^14.0.2", | ||
@@ -51,0 +53,0 @@ "graphql-iso-date": "^3.6.1", |
@@ -8,2 +8,3 @@ <p align="center"> | ||
[![npm version](https://badge.fury.io/js/nexus.svg)](https://badge.fury.io/js/nexus) | ||
[![Slack](https://slack.prisma.io/badge.svg)](https://slack.prisma.io/) | ||
@@ -10,0 +11,0 @@ Declarative, code-first and strongly typed GraphQL schema construction for TypeScript & JavaScript |
@@ -131,5 +131,15 @@ import * as path from "path"; | ||
import { decorateType } from "./definitions/decorateType"; | ||
import * as Plugins from "./plugins"; | ||
export type Maybe<T> = T | null; | ||
export type NexusAcceptedTypeDef = | ||
| AllNexusNamedTypeDefs | ||
| NexusExtendInputTypeDef<string> | ||
| NexusExtendTypeDef<string> | ||
| GraphQLNamedType | ||
| DynamicInputMethodDef<string> | ||
| DynamicOutputMethodDef<string> | ||
| DynamicOutputPropertyDef<string>; | ||
type NexusShapedOutput = { | ||
@@ -177,2 +187,3 @@ name: string; | ||
export interface BuilderConfig { | ||
plugins?: Plugins.PluginDef[]; | ||
/** | ||
@@ -195,3 +206,3 @@ * Generated artifact settings. Set to false to disable all. | ||
* | ||
* The default path is node_modules/@types/__nexus-typegen__core/index.d.ts. | ||
* The default path is node_modules/@types/nexus-typegen/index.d.ts. | ||
* This is chosen becuase TypeScript will pick it up without | ||
@@ -403,2 +414,8 @@ * any configuration needed by you. For more details about the @types | ||
/** | ||
* Used to track all _GraphQL_ types that have been added to the builder. | ||
* This supports hasType method which permits asking the question "Will | ||
* the GraphQL schema have _this_ type (name)". | ||
*/ | ||
protected allTypeDefs: Record<string, NexusAcceptedTypeDef> = {}; | ||
/** | ||
* Used to check for circular references. | ||
@@ -488,21 +505,13 @@ */ | ||
hasType = (typeName: string): boolean => { | ||
return Boolean(this.allTypeDefs[typeName]); | ||
}; | ||
/** | ||
* Add type takes a Nexus type, or a GraphQL type and pulls | ||
* it into an internal "type registry". It also does an initial pass | ||
* on any types that are referenced on the "types" field and pulls | ||
* those in too, so you can define types anonymously, without | ||
* exporting them. | ||
* | ||
* @param typeDef | ||
* Add type takes a Nexus type, or a GraphQL type and pulls it into an | ||
* internal "type registry". It also does an initial pass on any types that | ||
* are referenced on the "types" field and pulls those in too, so you can | ||
* define types anonymously, without exporting them. | ||
*/ | ||
addType( | ||
typeDef: | ||
| AllNexusNamedTypeDefs | ||
| NexusExtendInputTypeDef<string> | ||
| NexusExtendTypeDef<string> | ||
| GraphQLNamedType | ||
| DynamicInputMethodDef<string> | ||
| DynamicOutputMethodDef<string> | ||
| DynamicOutputPropertyDef<string> | ||
) { | ||
addType = (typeDef: NexusAcceptedTypeDef) => { | ||
if (isNexusDynamicInputMethod(typeDef)) { | ||
@@ -548,2 +557,6 @@ this.dynamicInputFields[typeDef.name] = typeDef; | ||
if (!this.allTypeDefs[typeDef.name]) { | ||
this.allTypeDefs[typeDef.name] = typeDef; | ||
} | ||
if (isNexusScalarTypeDef(typeDef) && typeDef.value.asNexusMethod) { | ||
@@ -588,3 +601,3 @@ this.dynamicInputFields[typeDef.value.asNexusMethod] = typeDef.name; | ||
} | ||
} | ||
}; | ||
@@ -1469,3 +1482,10 @@ walkTypes() { | ||
const builder = schemaBuilder || new SchemaBuilder(config); | ||
const plugins = config.plugins || []; | ||
const pluginControllers = plugins.map((plugin) => | ||
Plugins.initialize(builder, plugin) | ||
); | ||
addTypes(builder, types); | ||
pluginControllers.forEach((pluginController) => | ||
pluginController.triggerOnInstall() | ||
); | ||
return builder.getFinalTypeMap(); | ||
@@ -1472,0 +1492,0 @@ } |
@@ -32,2 +32,3 @@ import { | ||
DynamicOutputProperty = "DynamicOutputProperty", | ||
Plugin = "Plugin", | ||
} | ||
@@ -34,0 +35,0 @@ |
// All of the Public API definitions | ||
export { | ||
createPlugin, | ||
PluginConfig, | ||
PluginBuilderLens, | ||
PluginOnInstallHandler, | ||
} from "./plugins"; | ||
export { buildTypes, makeSchema } from "./builder"; | ||
@@ -3,0 +9,0 @@ export { |
@@ -483,3 +483,3 @@ import { | ||
argTypeMap[type.name][field.name] = field.args.reduce( | ||
(obj: Record<string, string[]>, arg) => { | ||
(obj: Record<string, [string, string]>, arg) => { | ||
obj[arg.name] = this.normalizeArg(arg); | ||
@@ -486,0 +486,0 @@ return obj; |
@@ -239,1 +239,35 @@ import { | ||
} | ||
/** | ||
* Calculate the venn diagram between two iterables based on reference equality | ||
* checks. The returned tripple contains items thusly: | ||
* | ||
* * items only in arg 1 --> first tripple slot | ||
* * items in args 1 & 2 --> second tripple slot | ||
* * items only in arg 2 --> third tripple slot | ||
*/ | ||
export function venn<T>( | ||
xs: Iterable<T>, | ||
ys: Iterable<T> | ||
): [Set<T>, Set<T>, Set<T>] { | ||
const lefts: Set<T> = new Set(xs); | ||
const boths: Set<T> = new Set(); | ||
const rights: Set<T> = new Set(ys); | ||
for (const l of lefts) { | ||
if (rights.has(l)) { | ||
boths.add(l); | ||
lefts.delete(l); | ||
rights.delete(l); | ||
} | ||
} | ||
for (const r of rights) { | ||
if (lefts.has(r)) { | ||
boths.add(r); | ||
lefts.delete(r); | ||
rights.delete(r); | ||
} | ||
} | ||
return [lefts, boths, rights]; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
715071
141
11128
117
18