Socket
Socket
Sign inDemoInstall

graphile-build

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphile-build - npm Package Compare versions

Comparing version 5.0.0-alpha.11 to 5.0.0-alpha.12

19

CHANGELOG.md
# graphile-build
## 5.0.0-alpha.12
### Patch Changes
- [#402](https://github.com/benjie/postgraphile-private/pull/402)
[`644938276`](https://github.com/benjie/postgraphile-private/commit/644938276ebd48c5486ba9736a525fcc66d7d714)
Thanks [@benjie](https://github.com/benjie)! - Use `file://` URLs in import()
to fix compatibility with Windows (e.g. when loading `graphile.config.mjs`)
- [#402](https://github.com/benjie/postgraphile-private/pull/402)
[`47365f0df`](https://github.com/benjie/postgraphile-private/commit/47365f0df2644fd91839a6698998e1463df8de79)
Thanks [@benjie](https://github.com/benjie)! - Add helper for more easily
handling NodeIDs for known typeName.
- Updated dependencies
[[`644938276`](https://github.com/benjie/postgraphile-private/commit/644938276ebd48c5486ba9736a525fcc66d7d714)]:
- graphile-config@0.0.1-alpha.5
- grafast@0.0.1-alpha.11
## 5.0.0-alpha.11

@@ -4,0 +23,0 @@

import "graphile-config";
import type { ExecutableStep, NodeIdCodec, NodeIdHandler } from "grafast";
type NodeFetcher = {
($nodeId: ExecutableStep<string>): ExecutableStep<any>;
deprecationReason?: string;
};
declare global {
namespace GraphileBuild {
interface Build {
specForHandler(handler: NodeIdHandler, codec: NodeIdCodec): (nodeId: string) => any;
nodeFetcherByTypeName(typeName: string): NodeFetcher;
}
interface Inflection {

@@ -13,2 +22,3 @@ nodeById(this: Inflection, typeName: string): string;

export declare const NodeAccessorPlugin: GraphileConfig.Plugin;
export {};
//# sourceMappingURL=NodeAccessorPlugin.d.ts.map

75

dist/plugins/NodeAccessorPlugin.js

@@ -8,21 +8,2 @@ "use strict";

const version_js_1 = require("../version.js");
const specForHandler = (handler, codec) => {
function spec(nodeId) {
// We only want to return the specifier if it matches
// this handler; otherwise return null.
try {
const specifier = codec.decode(nodeId);
if (handler.match(specifier)) {
return specifier;
}
}
catch {
// Ignore errors
}
return null;
}
spec.displayName = `specifier_${handler.typeName}_${handler.codecName}`;
spec.isSyncAndSafe = true; // Optimization
return spec;
};
exports.NodeAccessorPlugin = {

@@ -41,2 +22,45 @@ name: "NodeAccessorPlugin",

hooks: {
build(build) {
const nodeFetcherByTypeNameCache = new Map();
return build.extend(build, {
specForHandler: (0, utils_js_1.EXPORTABLE)(() => function (handler, codec) {
function spec(nodeId) {
// We only want to return the specifier if it matches
// this handler; otherwise return null.
try {
const specifier = codec.decode(nodeId);
if (handler.match(specifier)) {
return specifier;
}
}
catch {
// Ignore errors
}
return null;
}
spec.displayName = `specifier_${handler.typeName}_${handler.codecName}`;
spec.isSyncAndSafe = true; // Optimization
return spec;
}, []),
nodeFetcherByTypeName(typeName) {
const existing = nodeFetcherByTypeNameCache.get(typeName);
if (existing)
return existing;
const finalBuild = build;
const { specForHandler } = finalBuild;
const handler = finalBuild.getNodeIdHandler(typeName);
const codec = finalBuild.getNodeIdCodec(handler.codecName);
const fetcher = (0, utils_js_1.EXPORTABLE)((codec, handler, lambda, specForHandler) => {
const fn = ($nodeId) => {
const $decoded = lambda($nodeId, specForHandler(handler, codec));
return handler.get(handler.getSpec($decoded));
};
fn.deprecationReason = handler.deprecationReason;
return fn;
}, [codec, handler, grafast_1.lambda, specForHandler]);
nodeFetcherByTypeNameCache.set(typeName, fetcher);
return fetcher;
},
}, "Adding node accessor helpers");
},
GraphQLObjectType_fields(fields, build, context) {

@@ -58,4 +82,3 @@ if (!build.getNodeTypeNames) {

}
const handler = build.getNodeIdHandler(typeName);
const codec = build.getNodeIdCodec(handler.codecName);
const fetcher = build.nodeFetcherByTypeName(typeName);
return build.extend(memo, {

@@ -71,7 +94,7 @@ [build.inflection.nodeById(typeName)]: {

description: `Reads a single \`${typeName}\` using its globally unique \`ID\`.`,
deprecationReason: handler.deprecationReason,
plan: (0, utils_js_1.EXPORTABLE)((codec, handler, lambda, nodeIdFieldName, specForHandler) => function plan(_$parent, args) {
const $decoded = lambda(args.get(nodeIdFieldName), specForHandler(handler, codec));
return handler.get(handler.getSpec($decoded));
}, [codec, handler, grafast_1.lambda, nodeIdFieldName, specForHandler]),
deprecationReason: fetcher.deprecationReason,
plan: (0, utils_js_1.EXPORTABLE)((fetcher, nodeIdFieldName) => function plan(_$parent, args) {
const $nodeId = args.get(nodeIdFieldName);
return fetcher($nodeId);
}, [fetcher, nodeIdFieldName]),
},

@@ -78,0 +101,0 @@ }, `Adding ${typeName} by NodeId field`);

{
"name": "graphile-build",
"version": "5.0.0-alpha.11",
"version": "5.0.0-alpha.12",
"description": "Build a GraphQL schema from plugins",

@@ -44,3 +44,3 @@ "type": "commonjs",

"debug": "^4.3.3",
"graphile-config": "^0.0.1-alpha.4",
"graphile-config": "^0.0.1-alpha.5",
"lodash": "^4.17.21",

@@ -55,4 +55,4 @@ "pluralize": "^7.0.0",

"peerDependencies": {
"grafast": "^0.0.1-alpha.10",
"graphile-config": "^0.0.1-alpha.4",
"grafast": "^0.0.1-alpha.11",
"graphile-config": "^0.0.1-alpha.5",
"graphql": "^16.1.0-experimental-stream-defer.6"

@@ -59,0 +59,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc