graphile-build
Advanced tools
Comparing version 5.0.0-beta.15 to 5.0.0-beta.16
# graphile-build | ||
## 5.0.0-beta.16 | ||
### Patch Changes | ||
- [#1955](https://github.com/graphile/crystal/pull/1955) | ||
[`6c6be29f1`](https://github.com/graphile/crystal/commit/6c6be29f12b24782c926b2bc62ed2ede09ac05de) | ||
Thanks [@benjie](https://github.com/benjie)! - Steps are now prevented from | ||
calling other steps' lifecycle methods. GRAPHILE_ENV is actively encouraged, | ||
and falls back to NODE_ENV. | ||
- [#1949](https://github.com/graphile/crystal/pull/1949) | ||
[`179d25b09`](https://github.com/graphile/crystal/commit/179d25b09bb3272eeef564067b8e512d8de0112f) | ||
Thanks [@benjie](https://github.com/benjie)! - Add support for registering | ||
PgCodecs via plugins, add support for ltree type, improve error messages, no | ||
longer need to set a gather namespace to use cache/state. | ||
- [#1958](https://github.com/graphile/crystal/pull/1958) | ||
[`8315e8d01`](https://github.com/graphile/crystal/commit/8315e8d01c118cebc4ebbc53a2f264b958b252ad) | ||
Thanks [@benjie](https://github.com/benjie)! - EXPORTABLE now accepts a third | ||
argument, `nameHint`, which is used to hint what variable name to use for the | ||
given value. Used this in `graphile-export` along with some fixes and | ||
optimizations to improve the exports further. | ||
- [#1946](https://github.com/graphile/crystal/pull/1946) | ||
[`9d53dde72`](https://github.com/graphile/crystal/commit/9d53dde726b7304962e921b88a159649e49156e5) | ||
Thanks [@benjie](https://github.com/benjie)! - Exporting a schema now performs | ||
ESLint 'no-use-before-define' check to catch even more invalid export | ||
conditions. Fix `registerNodeIdCodec` calls caught by this. | ||
- Updated dependencies | ||
[[`9f85c614d`](https://github.com/graphile/crystal/commit/9f85c614d48dc745c5fed15333dbb75af7fddc88), | ||
[`6c6be29f1`](https://github.com/graphile/crystal/commit/6c6be29f12b24782c926b2bc62ed2ede09ac05de), | ||
[`8315e8d01`](https://github.com/graphile/crystal/commit/8315e8d01c118cebc4ebbc53a2f264b958b252ad)]: | ||
- grafast@0.1.1-beta.6 | ||
## 5.0.0-beta.15 | ||
@@ -4,0 +38,0 @@ |
@@ -161,3 +161,4 @@ import type { BaseGraphQLArguments, ExecutableStep, GrafastArgumentConfig, GrafastFieldConfig, GrafastFieldConfigArgumentMap, GrafastInputFieldConfig, GrafastInputFieldConfigMap, OutputPlanForType } from "grafast"; | ||
}): boolean; | ||
EXPORTABLE<T, TScope extends any[]>(factory: (...args: TScope) => T, args: [...TScope]): T; | ||
EXPORTABLE<T, TScope extends any[]>(factory: (...args: TScope) => T, args: [...TScope], nameHint?: string): T; | ||
exportNameHint(obj: any, nameHint: string): void; | ||
/** | ||
@@ -164,0 +165,0 @@ * Use `build.grafast` rather than importing `grafast` directly to try |
@@ -90,2 +90,5 @@ "use strict"; | ||
exports.buildInflection = buildInflection; | ||
function pluginNamespace(plugin) { | ||
return plugin.gather?.namespace ?? plugin.name; | ||
} | ||
/** | ||
@@ -108,12 +111,9 @@ * @internal | ||
const spec = plugin.gather; | ||
if (spec.namespace != null) { | ||
if (spec.namespace in globalState) { | ||
// ERRORS: track who registers which namespace, output more helpful error. | ||
throw new Error(`Namespace '${spec.namespace}' was already registered, it cannot be registered by two plugins - namespaces must be unique.`); | ||
} | ||
const specNamespace = pluginNamespace(plugin); | ||
if (specNamespace in globalState) { | ||
// ERRORS: track who registers which namespace, output more helpful error. | ||
throw new Error(`Namespace '${specNamespace}' was already registered, it cannot be registered by two plugins - namespaces must be unique. Latest plugin was '${plugin.name}'.`); | ||
} | ||
const cache = spec.namespace != null | ||
? (globalState[spec.namespace] = | ||
spec.initialCache?.() ?? Object.create(null)) | ||
: EMPTY_OBJECT; | ||
const cache = (globalState[specNamespace] = | ||
spec.initialCache?.() ?? Object.create(null)); | ||
if (typeof cache.then === "function") { | ||
@@ -136,12 +136,13 @@ // ENHANCE: can we just make `initialCache` allow promises? | ||
pluginContext.set(plugin, context); | ||
if (spec.namespace != null) { | ||
helpers[spec.namespace] = Object.create(null); | ||
if (spec.helpers != null) { | ||
const specHelpers = spec.helpers; | ||
for (const helperName of Object.keys(specHelpers)) { | ||
helpers[spec.namespace][helperName] = (...args) => { | ||
return specHelpers[helperName](context, ...args); | ||
}; | ||
} | ||
helpers[specNamespace] = Object.create(null); | ||
if (spec.helpers != null) { | ||
if (!spec.namespace) { | ||
throw new Error(`Plugin '${plugin.name}' tries to add helpers but is using an implicit namespace. Please use an explicit \`plugin.gather.namespace\`.`); | ||
} | ||
const specHelpers = spec.helpers; | ||
for (const helperName of Object.keys(specHelpers)) { | ||
helpers[specNamespace][helperName] = (...args) => { | ||
return specHelpers[helperName](context, ...args); | ||
}; | ||
} | ||
} | ||
@@ -162,9 +163,8 @@ } | ||
const spec = plugin.gather; | ||
const specNamespace = pluginNamespace(plugin); | ||
const context = pluginContext.get(plugin); | ||
if (spec.namespace != null) { | ||
const val = typeof spec.initialState === "function" | ||
? await spec.initialState(context.cache) | ||
: {}; | ||
context.state = gatherState[spec.namespace] = val; | ||
} | ||
const val = typeof spec.initialState === "function" | ||
? await spec.initialState(context.cache) | ||
: Object.create(null); | ||
context.state = gatherState[specNamespace] = val; | ||
} | ||
@@ -171,0 +171,0 @@ // Now call the main functions |
@@ -83,2 +83,3 @@ "use strict"; | ||
EXPORTABLE: utils_js_1.EXPORTABLE, | ||
exportNameHint: utils_js_1.exportNameHint, | ||
grafast, | ||
@@ -85,0 +86,0 @@ graphql, |
@@ -23,7 +23,8 @@ "use strict"; | ||
} | ||
build.registerNodeIdCodec({ | ||
const { EXPORTABLE } = build; | ||
build.registerNodeIdCodec(EXPORTABLE((base64JSONDecode, base64JSONEncode) => ({ | ||
name: "base64JSON", | ||
encode: base64JSONEncode, | ||
decode: base64JSONDecode, | ||
}); | ||
}), [base64JSONDecode, base64JSONEncode])); | ||
return _; | ||
@@ -30,0 +31,0 @@ }, |
@@ -23,7 +23,8 @@ "use strict"; | ||
} | ||
build.registerNodeIdCodec({ | ||
const { EXPORTABLE } = build; | ||
build.registerNodeIdCodec(EXPORTABLE((pipeStringDecode, pipeStringEncode) => ({ | ||
name: "pipeString", | ||
encode: pipeStringEncode, | ||
decode: pipeStringDecode, | ||
}); | ||
}), [pipeStringDecode, pipeStringEncode])); | ||
return _; | ||
@@ -30,0 +31,0 @@ }, |
import type { GraphQLNamedType, GraphQLScalarTypeConfig } from "grafast/graphql"; | ||
import { GraphQLObjectType } from "grafast/graphql"; | ||
export declare function EXPORTABLE<T, TScope extends any[]>(factory: (...args: TScope) => T, args: [...TScope]): T; | ||
export declare function EXPORTABLE<T, TScope extends any[]>(factory: (...args: TScope) => T, args: [...TScope], nameHint?: string): T; | ||
export declare function exportNameHint(obj: any, nameHint: string): void; | ||
/** | ||
@@ -5,0 +6,0 @@ * Loops over all the given `keys` and binds the method of that name on `obj` |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.gatherConfig = exports.stringTypeSpec = exports.wrapDescription = exports.isValidObjectType = exports.singularize = exports.pluralize = exports.upperCamelCase = exports.constantCase = exports.camelCase = exports.upperFirst = exports.formatInsideUnderscores = exports.constantCaseAll = exports.bindAll = exports.EXPORTABLE = void 0; | ||
exports.gatherConfig = exports.stringTypeSpec = exports.wrapDescription = exports.isValidObjectType = exports.singularize = exports.pluralize = exports.upperCamelCase = exports.constantCase = exports.camelCase = exports.upperFirst = exports.formatInsideUnderscores = exports.constantCaseAll = exports.bindAll = exports.exportNameHint = exports.EXPORTABLE = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -11,3 +11,3 @@ const grafast_1 = require("grafast"); | ||
const pluralize_1 = tslib_1.__importDefault(require("pluralize")); | ||
function EXPORTABLE(factory, args) { | ||
function EXPORTABLE(factory, args, nameHint) { | ||
const fn = factory(...args); | ||
@@ -19,2 +19,3 @@ if ((typeof fn === "function" || (typeof fn === "object" && fn !== null)) && | ||
$exporter$factory: { value: factory }, | ||
$exporter$name: { writable: true, value: nameHint }, | ||
}); | ||
@@ -25,2 +26,16 @@ } | ||
exports.EXPORTABLE = EXPORTABLE; | ||
function exportNameHint(obj, nameHint) { | ||
if ((typeof obj === "object" && obj != null) || typeof obj === "function") { | ||
if (!("$exporter$name" in obj)) { | ||
Object.defineProperty(obj, "$exporter$name", { | ||
writable: true, | ||
value: nameHint, | ||
}); | ||
} | ||
else if (!obj.$exporter$name) { | ||
obj.$exporter$name = nameHint; | ||
} | ||
} | ||
} | ||
exports.exportNameHint = exportNameHint; | ||
/** | ||
@@ -27,0 +42,0 @@ * Loops over all the given `keys` and binds the method of that name on `obj` |
@@ -1,2 +0,2 @@ | ||
export declare const version = "5.0.0-beta.15"; | ||
export declare const version = "5.0.0-beta.16"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// This file is autogenerated by /scripts/postversion.mjs | ||
exports.version = "5.0.0-beta.15"; | ||
exports.version = "5.0.0-beta.16"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "graphile-build", | ||
"version": "5.0.0-beta.15", | ||
"version": "5.0.0-beta.16", | ||
"description": "Build a GraphQL schema from plugins", | ||
@@ -55,3 +55,3 @@ "type": "commonjs", | ||
"peerDependencies": { | ||
"grafast": "^0.1.1-beta.5", | ||
"grafast": "^0.1.1-beta.6", | ||
"graphile-config": "^0.0.1-beta.7", | ||
@@ -67,3 +67,3 @@ "graphql": "^16.1.0-experimental-stream-defer.6" | ||
"@types/jest": "^29.5.4", | ||
"graphile-export": "^0.0.2-beta.10", | ||
"graphile-export": "^0.0.2-beta.11", | ||
"graphql": "16.1.0-experimental-stream-defer.6", | ||
@@ -70,0 +70,0 @@ "jest": "^29.6.4", |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
456965
5137