Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphile-export

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphile-export - npm Package Compare versions

Comparing version 0.0.2-beta.11 to 0.0.2-beta.12

56

CHANGELOG.md
# graphile-export
## 0.0.2-beta.12
### Patch Changes
- [#2050](https://github.com/graphile/crystal/pull/2050)
[`a4d4de334`](https://github.com/graphile/crystal/commit/a4d4de33435d3f6d04d9e627bcc3e77f6eb66c7b)
Thanks [@benjie](https://github.com/benjie)! - Graphile Export now
auto-detects that a function has additional properties set, and makes sure
these properties are exported too. (Typically this is `fn.isSyncAndSafe=true`
for Grafast optimization.)
- [#2050](https://github.com/graphile/crystal/pull/2050)
[`de24f1d14`](https://github.com/graphile/crystal/commit/de24f1d143a331f410cf4955a18b10a09790f7f8)
Thanks [@benjie](https://github.com/benjie)! - Fix exporting input object
inputPlan in typeDefs mode.
- [#1993](https://github.com/graphile/crystal/pull/1993)
[`fdc440eb3`](https://github.com/graphile/crystal/commit/fdc440eb31004114aa5e1d91d290414dd0587746)
Thanks [@benjie](https://github.com/benjie)! - Ability to export values from
graphile-export (e.g. the registry)
- [#2050](https://github.com/graphile/crystal/pull/2050)
[`0dbfbb687`](https://github.com/graphile/crystal/commit/0dbfbb68747f2755ba228afe22bf2da25348c71b)
Thanks [@benjie](https://github.com/benjie)! - Don't pass filePath to lintText
to avoid ESLint ignoring the file.
- Updated dependencies
[[`357d475f5`](https://github.com/graphile/crystal/commit/357d475f54fecc8c51892e0346d6872b34132430),
[`3551725e7`](https://github.com/graphile/crystal/commit/3551725e71c3ed876554e19e5ab2c1dcb0fb1143),
[`80836471e`](https://github.com/graphile/crystal/commit/80836471e5cedb29dee63bc5002550c4f1713cfd),
[`a5c20fefb`](https://github.com/graphile/crystal/commit/a5c20fefb571dea6d1187515dc48dd547e9e6204),
[`1ce08980e`](https://github.com/graphile/crystal/commit/1ce08980e2a52ed9bc81564d248c19648ecd3616),
[`ab08cbf9c`](https://github.com/graphile/crystal/commit/ab08cbf9c504c3cc22495a99a965e7634c18a6a3),
[`dff4f2535`](https://github.com/graphile/crystal/commit/dff4f2535ac6ce893089b312fcd5fffcd98573a5),
[`a287a57c2`](https://github.com/graphile/crystal/commit/a287a57c2765da0fb6a132ea0953f64453210ceb),
[`2fe56f9a6`](https://github.com/graphile/crystal/commit/2fe56f9a6dac03484ace45c29c2223a65f9ca1db),
[`fed603d71`](https://github.com/graphile/crystal/commit/fed603d719c02f33e12190f925c9e3b06c581fac),
[`ed6e0d278`](https://github.com/graphile/crystal/commit/ed6e0d2788217a1c419634837f4208013eaf2923),
[`e82e4911e`](https://github.com/graphile/crystal/commit/e82e4911e32138df1b90ec0fde555ea963018d21),
[`94a05064e`](https://github.com/graphile/crystal/commit/94a05064ea05108685ff71174a9f871ab5b4c147),
[`42ece5aa6`](https://github.com/graphile/crystal/commit/42ece5aa6ca05345ebc17fb5c7d55df3b79b7612),
[`e0d69e518`](https://github.com/graphile/crystal/commit/e0d69e518a98c70f9b90f59d243ce33978c1b5a1),
[`6699388ec`](https://github.com/graphile/crystal/commit/6699388ec167d35c71220ce5d9113cac578da6cb),
[`966203504`](https://github.com/graphile/crystal/commit/96620350467ab8c65b56adf2f055e19450f8e772),
[`c1645b249`](https://github.com/graphile/crystal/commit/c1645b249aae949a548cd916e536ccfb63e5ab35),
[`ed8bbaa3c`](https://github.com/graphile/crystal/commit/ed8bbaa3cd1563a7601ca8c6b0412633b0ea4ce9),
[`a0e82b9c5`](https://github.com/graphile/crystal/commit/a0e82b9c5f4e585f1af1e147299cd07944ece6f8),
[`14e2412ee`](https://github.com/graphile/crystal/commit/14e2412ee368e8d53abf6774c7f0069f32d4e8a3),
[`57ab0e1e7`](https://github.com/graphile/crystal/commit/57ab0e1e72c01213b21d3efc539cd655d83d993a),
[`8442242e4`](https://github.com/graphile/crystal/commit/8442242e43cac7d89ca0c413cf42c9fabf6f247f),
[`64ce7b765`](https://github.com/graphile/crystal/commit/64ce7b7650530251aec38a51089da66f914c19b4),
[`cba842357`](https://github.com/graphile/crystal/commit/cba84235786acbd77ade53bae7a3fba4a9be1eb7),
[`2fa77d0f2`](https://github.com/graphile/crystal/commit/2fa77d0f237cdb98d3dafb6b5e4083a2c6c38673)]:
- grafast@0.1.1-beta.7
- pg-sql2@5.0.0-beta.6
## 0.0.2-beta.11

@@ -4,0 +60,0 @@

3

dist/exportSchema.d.ts

@@ -13,3 +13,6 @@ /// <reference types="node" />

}>;
export declare function exportValueAsString(name: string, value: any, options: ExportOptions): Promise<{
code: string;
}>;
export declare function exportSchema(schema: GraphQLSchema, toPath: string | URL, options?: ExportOptions): Promise<void>;
//# sourceMappingURL=exportSchema.d.ts.map

125

dist/exportSchema.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.exportSchema = exports.exportSchemaAsString = exports.objectNullPrototype = exports.isNotNullish = exports.canRepresentAsIdentifier = void 0;
exports.exportSchema = exports.exportValueAsString = exports.exportSchemaAsString = exports.objectNullPrototype = exports.isNotNullish = exports.canRepresentAsIdentifier = void 0;
const tslib_1 = require("tslib");

@@ -192,2 +192,3 @@ const promises_1 = require("node:fs/promises");

this._values = new Map();
this._funcToAstCache = new Map();
}

@@ -673,2 +674,17 @@ addStatements(statements) {

};
function importWellKnownOrFactory(file, value, locationHint, nameHint) {
if (isImportable(value)) {
return file.import(value.$$export.moduleName, value.$$export.exportName);
}
else if ((0, wellKnown_js_1.wellKnown)(file.options, value)) {
const { moduleName, exportName } = (0, wellKnown_js_1.wellKnown)(file.options, value);
return file.import(moduleName, exportName);
}
else if (isExportedFromFactory(value)) {
return factoryAst(file, value, locationHint, nameHint);
}
else {
return undefined;
}
}
function convertToIdentifierViaAST(file, thing, baseNameHint, locationHint, depth = 0) {

@@ -683,5 +699,4 @@ const existingIdentifier = getExistingIdentifier(file, thing);

file._values.set(thing, variableIdentifier);
const ast = isExportedFromFactory(thing)
? factoryAst(file, thing, locationHint, nameHint)
: _convertToAST(file, thing, locationHint, nameHint, depth, variableIdentifier);
const ast = importWellKnownOrFactory(file, thing, locationHint, nameHint) ??
_convertToAST(file, thing, locationHint, nameHint, depth, variableIdentifier);
if (ast.type === "Identifier") {

@@ -734,15 +749,4 @@ console.warn(`graphile-export error: AST returned an identifier '${ast.name}'; this could cause an infinite loop.`);

// `(() => { const foo = 1, bar = 2; return /*>*/() => {return foo+bar}/*<*/})();`
if (isExportedFromFactory(fn)) {
return factoryAst(file, fn, locationHint, nameHint);
}
else if ((0, wellKnown_js_1.wellKnown)(file.options, fn)) {
const { moduleName, exportName } = (0, wellKnown_js_1.wellKnown)(file.options, fn);
return file.import(moduleName, exportName);
}
else if (isImportable(fn)) {
return file.import(fn.$$export.moduleName, fn.$$export.exportName);
}
else {
return funcToAst(fn, locationHint, nameHint);
}
return (importWellKnownOrFactory(file, fn, locationHint, nameHint) ??
funcToAst(file, fn, locationHint, nameHint).ast);
}

@@ -752,3 +756,3 @@ const shouldOptimizeFactoryCalls = true;

const factory = fn.$exporter$factory;
const funcAST = funcToAst(factory, locationHint, nameHint);
const { functionWithoutOwnAttributesAST: funcAST } = funcToAst(file, factory, locationHint, nameHint);
const depArgs = fn.$exporter$args.map((arg, i) => {

@@ -805,3 +809,6 @@ if (typeof arg === "string") {

}
function funcToAst(fn, locationHint, _nameHint) {
function funcToAst(file, fn, locationHint, _nameHint) {
if (file._funcToAstCache.has(fn)) {
return file._funcToAstCache.get(fn);
}
const path = _funcToAst(fn, locationHint, _nameHint);

@@ -831,3 +838,24 @@ const externalReferences = new Set();

}
return path.node;
const fnExpression = path.node;
const ownProps = Object.entries(fn);
const result = (() => {
if (ownProps.length > 0) {
// Need to assign things to it
const properties = ownProps.map(([key, value]) => {
return t.objectProperty(identifierOrLiteral(key), convertToIdentifierViaAST(file, value, `${locationHint}.${key}`, `${locationHint}['${key}']`));
});
return {
functionWithoutOwnAttributesAST: fnExpression,
ast: t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("assign")), [fnExpression, t.objectExpression(properties)]),
};
}
else {
return {
functionWithoutOwnAttributesAST: fnExpression,
ast: fnExpression,
};
}
})();
file._funcToAstCache.set(fn, result);
return result;
}

@@ -917,10 +945,5 @@ function parseExpressionViaDoc(funcString) {

extensions: extensions(file, config.extensions, "schema.extensions", "schema.extensions"),
enableDeferStream: t.booleanLiteral(process.env.ENABLE_DEFER_STREAM === "1"),
/*
// TODO: use the below once https://github.com/graphql/graphql-js/pull/3450 is fixed:
enableDeferStream:
config.enableDeferStream != null
enableDeferStream: config.enableDeferStream != null
? t.booleanLiteral(config.enableDeferStream)
: null,
*/
assumeValid: null, // TODO: t.booleanLiteral(true),

@@ -1001,2 +1024,5 @@ }));

const typeProperties = [];
if (type.extensions?.grafast?.inputPlan) {
typeProperties.push(t.objectProperty(identifierOrLiteral("__inputPlan"), convertToIdentifierViaAST(file, type.extensions?.grafast.inputPlan, `${type.name}.inputPlan`, `${type.name}.extensions.grafast.inputPlan`)));
}
for (const [fieldName, field] of Object.entries(type.toConfig().fields)) {

@@ -1021,7 +1047,16 @@ typeProperties.push(t.objectProperty(identifierOrLiteral(fieldName), convertToIdentifierViaAST(file, field.extensions?.grafast, `${type.name}.${fieldName}`, `${type.name}.fields[${fieldName}].extensions.grafast`)));

: null;
if (planAST) {
if (planAST ||
type.serialize !== graphql_1.GraphQLScalarType.prototype.serialize ||
type.parseValue !== graphql_1.GraphQLScalarType.prototype.parseValue ||
type.parseLiteral !== graphql_1.GraphQLScalarType.prototype.parseLiteral) {
plansProperties.push(t.objectProperty(identifierOrLiteral(type.name), t.objectExpression(objectToObjectProperties({
serialize: convertToIdentifierViaAST(file, type.serialize, `${type.name}Serialize`, `${type.name}.serialize`),
parseValue: convertToIdentifierViaAST(file, type.parseValue, `${type.name}ParseValue`, `${type.name}.parseValue`),
parseLiteral: convertToIdentifierViaAST(file, type.parseLiteral, `${type.name}ParseLiteral`, `${type.name}.parseLiteral`),
serialize: type.serialize !== graphql_1.GraphQLScalarType.prototype.serialize
? convertToIdentifierViaAST(file, type.serialize, `${type.name}Serialize`, `${type.name}.serialize`)
: null,
parseValue: type.parseValue !== graphql_1.GraphQLScalarType.prototype.parseValue
? convertToIdentifierViaAST(file, type.parseValue, `${type.name}ParseValue`, `${type.name}.parseValue`)
: null,
parseLiteral: type.parseLiteral !== graphql_1.GraphQLScalarType.prototype.parseLiteral
? convertToIdentifierViaAST(file, type.parseLiteral, `${type.name}ParseLiteral`, `${type.name}.parseLiteral`)
: null,
plan: planAST,

@@ -1088,2 +1123,7 @@ }))));

].includes(d.name));
if (process.env.ENABLE_DEFER_STREAM === "1" ||
config.directives.some((d) => d.name === "defer" || d.name === "skip")) {
// Ref: https://github.com/graphql/graphql-js/pull/3450
config.enableDeferStream = true;
}
const file = new CodegenFile(options);

@@ -1104,2 +1144,6 @@ const schemaExportDetails = {

}
return exportFile(file);
}
exports.exportSchemaAsString = exportSchemaAsString;
function exportFile(file) {
const ast = file.toAST();

@@ -1110,3 +1154,12 @@ const optimizedAst = (0, index_js_1.optimize)(ast);

}
exports.exportSchemaAsString = exportSchemaAsString;
async function exportValueAsString(name, value, options) {
const file = new CodegenFile(options);
const exportName = file.makeVariable(name);
const valueAST = convertToIdentifierViaAST(file, value, name, name);
file.addStatements(t.exportNamedDeclaration(t.variableDeclaration("const", [
t.variableDeclarator(exportName, valueAST),
])));
return exportFile(file);
}
exports.exportValueAsString = exportValueAsString;
async function loadESLint() {

@@ -1126,2 +1179,3 @@ try {

}
const filePath = typeof rawFilePath === "string" ? rawFilePath : rawFilePath.pathname;
const { ESLint } = eslintModule;

@@ -1152,9 +1206,12 @@ const eslint = new ESLint({

});
const filePath = typeof rawFilePath === "string" ? rawFilePath : rawFilePath.pathname;
const results = await eslint.lintText(code, { filePath });
const results = await eslint.lintText(code, {
warnIgnored: true,
// DO NOT PASS THE `filePath`; it can result in the file being ignored!
});
if (results.length !== 1) {
console.dir({ filePath, results });
throw new Error(`Expected ESLint results to have exactly one entry`);
}
const [result] = results;
if (result.errorCount > 0) {
if (result.warningCount > 0 || result.errorCount > 0) {
console.log(`ESLint found problems in the export; this likely indicates some issue with \`EXPORTABLE\` calls`);

@@ -1161,0 +1218,0 @@ const formatter = await eslint.loadFormatter("stylish");

@@ -1,4 +0,4 @@

export { exportSchema, exportSchemaAsString } from "./exportSchema.js";
export { exportSchema, exportSchemaAsString, exportValueAsString, } from "./exportSchema.js";
export { EXPORTABLE } from "./helpers.js";
export type { ExportOptions } from "./interfaces.js";
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EXPORTABLE = exports.exportSchemaAsString = exports.exportSchema = void 0;
exports.EXPORTABLE = exports.exportValueAsString = exports.exportSchemaAsString = exports.exportSchema = void 0;
var exportSchema_js_1 = require("./exportSchema.js");
Object.defineProperty(exports, "exportSchema", { enumerable: true, get: function () { return exportSchema_js_1.exportSchema; } });
Object.defineProperty(exports, "exportSchemaAsString", { enumerable: true, get: function () { return exportSchema_js_1.exportSchemaAsString; } });
Object.defineProperty(exports, "exportValueAsString", { enumerable: true, get: function () { return exportSchema_js_1.exportValueAsString; } });
var helpers_js_1 = require("./helpers.js");
Object.defineProperty(exports, "EXPORTABLE", { enumerable: true, get: function () { return helpers_js_1.EXPORTABLE; } });
//# sourceMappingURL=index.js.map
{
"name": "graphile-export",
"version": "0.0.2-beta.11",
"version": "0.0.2-beta.12",
"description": "Export in-memory generated GraphQL schemas to JS files when built with our helpers.",

@@ -57,4 +57,4 @@ "type": "commonjs",

"eslint": "^8.48.0",
"grafast": "^0.1.1-beta.6",
"pg-sql2": "^5.0.0-beta.5"
"grafast": "^0.1.1-beta.7",
"pg-sql2": "^5.0.0-beta.6"
},

@@ -61,0 +61,0 @@ "peerDependenciesMeta": {

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

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