🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

graphql-static-binding

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-static-binding - npm Package Compare versions

Comparing version

to
0.5.0

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

import { GraphQLFieldMap } from 'graphql';
import { Generator } from '../types';
export declare const generator: Generator;
export declare function renderExistsFields(fields: GraphQLFieldMap<any, any>): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
exports.generator = {

@@ -11,4 +12,25 @@ Main: renderMainMethod,

function renderMainMethod(queryType, mutationType, subscriptionType) {
return "module.exports.Graphcool = class Binding extends Graphcool {\n \n constructor({ endpoint, secret, fragmentReplacements, debug }) {\n super({ typeDefs, endpoint, secret, fragmentReplacements, debug });\n\n var self = this\n this.query = {\n" + renderMainMethodFields('query', queryType.getFields()) + "\n }" + (mutationType ? "\n \n this.mutation = {\n" + renderMainMethodFields('mutation', mutationType.getFields()) + "\n }" : '') + "\n }\n \n delegate(operation, field, args, context, info) {\n return super.delegate(operation, field, args, context, info)\n }\n}";
return "module.exports.Graphcool = class Binding extends Graphcool {\n \n constructor({ endpoint, secret, fragmentReplacements, debug }) {\n super({ typeDefs, endpoint, secret, fragmentReplacements, debug });\n\n var self = this\n this.exists = {\n" + renderExistsFields(queryType.getFields()) + "\n }\n\n this.query = {\n" + renderMainMethodFields('query', queryType.getFields()) + "\n }" + (mutationType ? "\n \n this.mutation = {\n" + renderMainMethodFields('mutation', mutationType.getFields()) + "\n }" : '') + "\n }\n \n delegate(operation, field, args, context, info) {\n return super.delegate(operation, field, args, context, info)\n }\n}";
}
function renderExistsFields(fields) {
return Object.keys(fields)
.map(function (f) {
var field = fields[f];
var type = field.type;
var foundList = false;
// Traverse the wrapping types (if any)
while (graphql_1.isWrappingType(type)) {
type = type.ofType;
// One of those wrappings need to be a GraphQLList for this field to qualify
foundList = foundList || graphql_1.isListType(type);
}
if (foundList) {
var whereType = field.args.find(function (a) { return a.name === 'where'; }).type.name;
return " " + type.name + "(where) {\n return super.existsDelegate('query', '" + field.name + "', { where }, {}, '{ id }')\n }";
}
})
.filter(function (f) { return f; })
.join(',\n');
}
exports.renderExistsFields = renderExistsFields;
function renderMainMethodFields(operation, fields) {

@@ -15,0 +37,0 @@ return Object.keys(fields).map(function (f) {

import { GraphQLFieldMap } from 'graphql';
import { Generator } from '../types';
export declare const generator: Generator;
export declare function renderExistsFields(fields: GraphQLFieldMap<any, any>): string;
export declare function renderMainMethodFields(operation: string, fields: GraphQLFieldMap<any, any>): string;

@@ -27,6 +27,27 @@ "use strict";

function renderMainMethod(queryType, mutationType, subscriptionType) {
return "export class Graphcool extends BaseGraphcool {\n \n constructor({ endpoint, secret, fragmentReplacements, debug }: BaseGraphcoolOptions) {\n super({ typeDefs, endpoint, secret, fragmentReplacements, debug });\n }\n \n query: Query = {\n" + renderMainMethodFields('query', queryType.getFields()) + "\n }" + (mutationType
return "export class Graphcool extends BaseGraphcool {\n \n constructor({ endpoint, secret, fragmentReplacements, debug }: BaseGraphcoolOptions) {\n super({ typeDefs, endpoint, secret, fragmentReplacements, debug });\n }\n\n exists = {\n" + renderExistsFields(queryType.getFields()) + "\n }\n \n query: Query = {\n" + renderMainMethodFields('query', queryType.getFields()) + "\n }" + (mutationType
? "\n\n mutation: Mutation = {\n" + renderMainMethodFields('mutation', mutationType.getFields()) + "\n }"
: '') + "\n}";
}
function renderExistsFields(fields) {
return Object.keys(fields)
.map(function (f) {
var field = fields[f];
var type = field.type;
var foundList = false;
// Traverse the wrapping types (if any)
while (graphql_1.isWrappingType(type)) {
type = type.ofType;
// One of those wrappings need to be a GraphQLList for this field to qualify
foundList = foundList || graphql_1.isListType(type);
}
if (foundList) {
var whereType = field.args.find(function (a) { return a.name === 'where'; }).type.name;
return " " + type.name + ": (where: " + whereType + "): Promise<boolean> => super.existsDelegate('query', '" + field.name + "', { where }, {}, '{ id }')";
}
})
.filter(function (f) { return f; })
.join(',\n');
}
exports.renderExistsFields = renderExistsFields;
function renderMainMethodFields(operation, fields) {

@@ -111,3 +132,3 @@ return Object.keys(fields)

if (graphql_1.isListType(type)) {
return "Array<" + renderFieldType(type.ofType) + ">";
return renderFieldType(type.ofType) + "[]";
}

@@ -121,3 +142,4 @@ return "" + type.name + (type.name === 'ID' ? '_Output' : '');

if (graphql_1.isListType(type)) {
return "Array<" + renderInputFieldType(type.ofType) + "> | " + renderInputFieldType(type.ofType);
var inputType = renderInputFieldType(type.ofType);
return inputType + "[] | " + inputType;
}

@@ -124,0 +146,0 @@ return "" + type.name + (type.name === 'ID' ? '_Input' : '');

{
"name": "graphql-static-binding",
"version": "0.4.0",
"version": "0.5.0",
"description": "Generate static binding files for a GraphQL schema",

@@ -10,2 +10,4 @@ "main": "dist/index.js",

"build": "rm -rf dist && tsc -d",
"test": "nyc cucumber-js --compiler ts:ts-node/register test/features/ -r test/step_definitions/ -f json:test/report/cucumber_report.json",
"dposttest": "node test/createReport.js && nyc report --reporter=text-lcov | coveralls",
"semantic-release": "semantic-release"

@@ -18,10 +20,38 @@ },

"license": "MIT",
"nyc": {
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"include": [
"src/**/*.ts"
],
"exclude": [
"**/*.d.ts"
],
"reporter": [
"text",
"lcov",
"json"
],
"all": true,
"sourceMap": true,
"instrument": true
},
"dependencies": {
"cucumber-html-reporter": "^3.0.4",
"graphql": "0.12.3"
},
"devDependencies": {
"@types/cucumber": "3.1.1",
"@types/graphql": "0.11.7",
"@types/node": "8.5.2",
"coveralls": "3.0.0",
"cucumber": "3.2.0",
"nyc": "11.4.1",
"semantic-release": "11.1.0",
"ts-node": "4.1.0",
"typescript": "2.6.2",
"semantic-release": "11.1.0"
"typescript": "2.6.2"
},

@@ -28,0 +58,0 @@ "repository": {

# graphql-static-binding [![npm](https://img.shields.io/npm/v/graphql-static-binding.svg?style=for-the-badge)](https://www.npmjs.com/package/graphql-static-binding)[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge)](https://github.com/semantic-release/semantic-release)
[![Travis](https://img.shields.io/travis/supergraphql/graphql-static-binding.svg?style=for-the-badge)](https://travis-ci.org/supergraphql/graphql-static-binding)[![Greenkeeper badge](https://img.shields.io/badge/renovate-enabled-brightgreen.svg?style=for-the-badge)](https://renovateapp.com/)[![Code Climate](https://img.shields.io/codeclimate/maintainability/supergraphql/graphql-static-binding.svg?style=for-the-badge)](https://codeclimate.com/github/supergraphql/graphql-static-binding)
[![Travis](https://img.shields.io/travis/supergraphql/graphql-static-binding.svg?style=for-the-badge)](https://travis-ci.org/supergraphql/graphql-static-binding)[![Greenkeeper badge](https://img.shields.io/badge/renovate-enabled-brightgreen.svg?style=for-the-badge)](https://renovateapp.com/)[![Code Climate](https://img.shields.io/codeclimate/maintainability/supergraphql/graphql-static-binding.svg?style=for-the-badge)](https://codeclimate.com/github/supergraphql/graphql-static-binding)[![Code Climate](https://img.shields.io/codeclimate/c/supergraphql/graphql-static-binding.svg?style=for-the-badge)](https://codeclimate.com/github/supergraphql/graphql-static-binding)
Generate static binding files for a GraphQL schema

@@ -4,0 +4,0 @@ <hr>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet