🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more →
Sign In

generate-graphql-client

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generate-graphql-client - npm Package Compare versions

Comparing version
3.1.2
to
3.2.0
+23
-1
lib/core/context.js

@@ -161,2 +161,12 @@ "use strict";

}
if (this.options.beautify) {
return (indent +
'/**\n' +
indent +
' *' +
comments.join('\n') +
'\n' +
indent +
' */\n');
}
return indent + '/**' + comments.join('\n') + ' */\n';

@@ -171,2 +181,3 @@ };

Context.prototype.getCode = function () {
var _this = this;
var _a;

@@ -202,7 +213,18 @@ var blocks = __spreadArray([], this.codeBlocks, true);

});
if (this.options.disableEslint) {
lines.push('/* eslint-disable */');
}
if (!this.options.skipGeneratedMessage) {
lines.push('/* This file was automatically generated and should not be edited. */');
}
blocks.forEach(function (block) {
if (lines.length && lines[lines.length - 1] !== '') {
lines.push('');
}
blocks.forEach(function (block, index, array) {
lines.push(block.code);
if (_this.options.beautify) {
if (index + 1 !== array.length) {
lines.push('');
}
}
});

@@ -209,0 +231,0 @@ return lines.join('\n');

+4
-1

@@ -22,3 +22,6 @@ "use strict";

}
ctx.addCode('operation', typeName, "export type ".concat(typeName, " = {\n") +
var comment = ctx.generateComment({
description: 'The GraphQL operation.'
});
ctx.addCode('operation', typeName, "".concat(comment, "export type ").concat(typeName, " = {\n") +
ctx.indent(1, "query?: $Operation<".concat(queryFields, ">\n")) +

@@ -25,0 +28,0 @@ ctx.indent(1, "mutation?: $Operation<".concat(mutationFields, ">\n")) +

@@ -125,2 +125,4 @@ "use strict";

mergeOption('headers');
mergeOption('beautify');
mergeOption('disableEslint');
mergeOption('skipGeneratedMessage');

@@ -127,0 +129,0 @@ mergeOption('skipWrappingEnum');

@@ -145,3 +145,3 @@ "use strict";

var operation = type === 'query' ? 'Q' : 'M';
var methods = JSON.stringify(names.join('/'));
var methods = "'".concat(names.join('/'), "'");
write(1, "const ".concat(varname, " = attach(").concat(operation, ", ").concat(methods, ")"));

@@ -169,3 +169,3 @@ };

write(2, 'queries: queries as {');
queryProps.forEach(function (line, index, array) {
queryProps.forEach(function (line) {
var prop = line

@@ -175,3 +175,3 @@ .split(/\n/)

.join('\n');
write(0, prop + (index + 1 === array.length ? '' : ','));
write(0, prop);
});

@@ -182,3 +182,3 @@ write(2, '}' + (hasMutations ? ',' : ''));

write(2, 'mutations: mutations as {');
mutationProps.forEach(function (line, index, array) {
mutationProps.forEach(function (line) {
var prop = line

@@ -188,3 +188,3 @@ .split(/\n/)

.join('\n');
write(0, prop + (index + 1 === array.length ? '' : ','));
write(0, prop);
});

@@ -191,0 +191,0 @@ write(2, '}');

@@ -99,7 +99,7 @@ export interface Configuration {

* {
* "Phone": "CellPhone"
* "BigInt": "_BigInt"
* }
* ```
*
* The above config will rename the type `Phone` to `CellPhone`.
* The above config will rename the type `BigInt` to `_BigInt`.
*

@@ -117,6 +117,15 @@ * Please note that the custom name cannot be used in the schema, and

/**
* The file headers.
* Lines to insert at the top of the file.
*/
headers?: string[];
/**
* Beautify comment formatting and separate code blocks using
* blank lines.
*/
beautify?: boolean;
/**
* Add an `eslint-disable` comment at the top of the file.
*/
disableEslint?: boolean;
/**
* Skip generating the generated message.

@@ -123,0 +132,0 @@ */

{
"name": "generate-graphql-client",
"description": "Generate GraphQL clients (in TypeScript) from GraphQL schemas.",
"version": "3.1.2",
"version": "3.2.0",
"main": "./lib/index.js",

@@ -14,12 +14,2 @@ "types": "./lib/index.d.ts",

},
"scripts": {
"build": "tsc",
"dev": "tsc && generate-graphql-introspection -s example/schema.graphql -o example/introspection.json && node ./bin/generate-graphql-client --config example/config.json",
"build:example": "npm run example:github && npm run example:gitlab",
"example:github": "tsc && generate-graphql-introspection -s example/github/github.graphql -o example/github/github.json && node ./bin/generate-graphql-client --config example/github/config.json",
"example:gitlab": "tsc && generate-graphql-introspection -s example/gitlab/gitlab.graphql -o example/gitlab/gitlab.json && node ./bin/generate-graphql-client --config example/gitlab/config.json",
"format": "prettier --write .",
"lint": "eslint --ext .js,.ts,.tsx ./src",
"lint:fix": "eslint --fix --ext .js,.ts,.tsx ./src"
},
"dependencies": {

@@ -35,6 +25,6 @@ "resolve-cli-args": "^1.1.0"

"eslint-config-prettier": "^8.10.0",
"generate-graphql-introspection": "workspace:^",
"generate-graphql-query": "workspace:^",
"prettier": "2.8.8",
"typescript": "5.1.6"
"typescript": "5.1.6",
"generate-graphql-introspection": "^1.1.0",
"generate-graphql-query": "^3.2.0"
},

@@ -62,3 +52,13 @@ "homepage": "https://github.com/john-yuan/graphql-toolkit/tree/main/packages/generate-graphql-client",

},
"license": "MIT"
}
"license": "MIT",
"scripts": {
"build": "tsc",
"dev": "tsc && generate-graphql-introspection -s example/schema.graphql -o example/introspection.json && node ./bin/generate-graphql-client --config example/config.json",
"build:example": "npm run example:github && npm run example:gitlab",
"example:github": "tsc && generate-graphql-introspection -s example/github/github.graphql -o example/github/github.json && node ./bin/generate-graphql-client --config example/github/config.json",
"example:gitlab": "tsc && generate-graphql-introspection -s example/gitlab/gitlab.graphql -o example/gitlab/gitlab.json && node ./bin/generate-graphql-client --config example/gitlab/config.json",
"format": "prettier --write .",
"lint": "eslint --ext .js,.ts,.tsx ./src",
"lint:fix": "eslint --fix --ext .js,.ts,.tsx ./src"
}
}

@@ -74,2 +74,6 @@ # README

generate({
options: {
beautify: true,
disableEslint: true
},
files: [

@@ -743,7 +747,7 @@ {

* {
* "Phone": "CellPhone"
* "BigInt": "_BigInt"
* }
* ```
*
* The above config will rename the type `Phone` to `CellPhone`.
* The above config will rename the type `BigInt` to `_BigInt`.
*

@@ -762,3 +766,3 @@ * Please note that the custom name cannot be used in the schema, and

/**
* The file headers.
* Lines to insert at the top of the file.
*/

@@ -768,2 +772,13 @@ headers?: string[]

/**
* Beautify comment formatting and separate code blocks using
* blank lines.
*/
beautify?: boolean
/**
* Add an `eslint-disable` comment at the top of the file.
*/
disableEslint?: boolean
/**
* Skip generating the generated message.

@@ -770,0 +785,0 @@ */