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

graphql-codegen-core

Package Overview
Dependencies
Maintainers
1
Versions
1651
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-codegen-core - npm Package Compare versions

Comparing version 0.6.0-alpha.d381584b to 0.6.0-alpha.d5fe220f

dist/operations/build-selection-set.d.ts

4

dist/index.d.ts
export { schemaToTemplateContext } from './schema/schema-to-template-context';
export { validateIntrospection } from './utils/introspection-to-schema';
export { transformDocument } from './operations/transform-document';
export { validateIntrospection, introspectionToGraphQLSchema } from './utils/introspection-to-schema';
export { Argument, Field, Type, Scalar, Enum, EnumValue, Union, Interface, SchemaTemplateContext, Document, Variable, Operation, Fragment, SelectionSetItem, SelectionSetFieldNode, SelectionSetFragmentSpread, SelectionSetInlineFragment, isFieldNode, isFragmentSpreadNode, isInlineFragmentNode } from './types';

@@ -5,4 +5,11 @@ "use strict";

exports.schemaToTemplateContext = schema_to_template_context_1.schemaToTemplateContext;
var transform_document_1 = require("./operations/transform-document");
exports.transformDocument = transform_document_1.transformDocument;
var introspection_to_schema_1 = require("./utils/introspection-to-schema");
exports.validateIntrospection = introspection_to_schema_1.validateIntrospection;
exports.introspectionToGraphQLSchema = introspection_to_schema_1.introspectionToGraphQLSchema;
var types_1 = require("./types");
exports.isFieldNode = types_1.isFieldNode;
exports.isFragmentSpreadNode = types_1.isFragmentSpreadNode;
exports.isInlineFragmentNode = types_1.isInlineFragmentNode;
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var resolve_type_1 = require("./resolve-type");
var resolve_type_indicators_1 = require("./resolve-type-indicators");
function resolveArguments(args) {
return args.map(function (arg) {
var type = resolve_type_1.resolveType(arg.type);
var namedType = graphql_1.getNamedType(arg.type);
var indicators = resolve_type_indicators_1.resolveTypeIndicators(namedType);
return {

@@ -13,2 +17,8 @@ name: arg.name,

isArray: type.isArray,
isEnum: indicators.isEnum,
isScalar: indicators.isScalar,
isInterface: indicators.isInterface,
isUnion: indicators.isUnion,
isInputType: indicators.isInputType,
isType: indicators.isType,
};

@@ -15,0 +25,0 @@ });

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

import { GraphQLInputType, GraphQLOutputType } from 'graphql';
import { GraphQLInputType, GraphQLOutputType, GraphQLType } from 'graphql';
export interface ResolvedType {

@@ -9,2 +9,2 @@ name: string;

export declare function isArray(type: GraphQLOutputType | GraphQLInputType): boolean;
export declare function resolveType(type: GraphQLOutputType | GraphQLInputType): ResolvedType;
export declare function resolveType(type: GraphQLType): ResolvedType;

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

var transform_scalar_1 = require("./transform-scalar");
var GRAPHQL_PRIMITIVES = ['String', 'Int', 'Boolean'];
var GRAPHQL_PRIMITIVES = ['String', 'Int', 'Boolean', 'ID', 'Float'];
var clearTypes = function (typesMap) { return Object.keys(typesMap)

@@ -26,2 +26,8 @@ .filter(function (key) { return !GRAPHQL_PRIMITIVES.includes(key) && !key.startsWith('__'); })

interfaces: [],
hasTypes: false,
hasInputTypes: false,
hasEnums: false,
hasUnions: false,
hasScalars: false,
hasInterfaces: false,
};

@@ -55,2 +61,8 @@ var rawTypesMap = schema.getTypeMap();

});
result.hasTypes = result.types.length > 0;
result.hasInputTypes = result.inputTypes.length > 0;
result.hasEnums = result.enums.length > 0;
result.hasUnions = result.unions.length > 0;
result.hasScalars = result.scalars.length > 0;
result.hasInterfaces = result.interfaces.length > 0;
return result;

@@ -57,0 +69,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var object_map_to_array_1 = require("../utils/object-map-to-array");
var resolve_type_1 = require("./resolve-type");
var resolve_arguments_1 = require("./resolve-arguments");
var resolve_type_indicators_1 = require("./resolve-type-indicators");
function resolveFields(rawFields) {

@@ -10,9 +12,19 @@ var fieldsArray = object_map_to_array_1.objectMapToArray(rawFields);

var type = resolve_type_1.resolveType(item.value.type);
var resolvedArguments = resolve_arguments_1.resolveArguments(item.value.args || []);
var namedType = graphql_1.getNamedType(item.value.type);
var indicators = resolve_type_indicators_1.resolveTypeIndicators(namedType);
return {
name: item.value.name,
description: item.value.description || '',
arguments: resolve_arguments_1.resolveArguments(item.value.args || []),
arguments: resolvedArguments,
type: type.name,
isArray: type.isArray,
isRequired: type.isRequired,
hasArguments: resolvedArguments.length > 0,
isEnum: indicators.isEnum,
isScalar: indicators.isScalar,
isInterface: indicators.isInterface,
isUnion: indicators.isUnion,
isInputType: indicators.isInputType,
isType: indicators.isType,
};

@@ -19,0 +31,0 @@ });

@@ -5,6 +5,8 @@ "use strict";

function transformInterface(gqlInterface) {
var resolvedFields = transform_fields_1.resolveFields(gqlInterface.getFields());
return {
name: gqlInterface.name,
description: gqlInterface.description || '',
fields: transform_fields_1.resolveFields(gqlInterface.getFields()),
fields: resolvedFields,
hasFields: resolvedFields.length > 0,
};

@@ -11,0 +13,0 @@ }

@@ -6,8 +6,12 @@ "use strict";

function transformGraphQLObject(object) {
var resolvedFields = transform_fields_1.resolveFields(object.getFields());
var resolvedInterfaces = object instanceof graphql_1.GraphQLObjectType ? object.getInterfaces().map(function (inf) { return inf.name; }) : [];
return {
name: object.name,
description: object.description || '',
fields: transform_fields_1.resolveFields(object.getFields()),
interfaces: object instanceof graphql_1.GraphQLObjectType ? object.getInterfaces().map(function (inf) { return inf.name; }) : [],
fields: resolvedFields,
interfaces: resolvedInterfaces,
isInputType: object instanceof graphql_1.GraphQLInputObjectType,
hasFields: resolvedFields.length > 0,
hasInterfaces: resolvedInterfaces.length > 0,
};

@@ -14,0 +18,0 @@ }

@@ -7,2 +7,8 @@ export interface Argument {

isArray: boolean;
isType: boolean;
isScalar: boolean;
isInterface: boolean;
isUnion: boolean;
isInputType: boolean;
isEnum: boolean;
}

@@ -16,2 +22,9 @@ export interface Field {

isRequired: boolean;
hasArguments: boolean;
isType: boolean;
isScalar: boolean;
isInterface: boolean;
isUnion: boolean;
isInputType: boolean;
isEnum: boolean;
}

@@ -24,2 +37,4 @@ export interface Type {

interfaces: string[];
hasFields: boolean;
hasInterfaces: boolean;
}

@@ -49,2 +64,3 @@ export interface Scalar {

fields: Field[];
hasFields: boolean;
}

@@ -58,2 +74,67 @@ export interface SchemaTemplateContext {

scalars: Scalar[];
hasTypes: boolean;
hasInputTypes: boolean;
hasEnums: boolean;
hasUnions: boolean;
hasScalars: boolean;
hasInterfaces: boolean;
}
export interface SelectionSetItem {
isFragmentSpread: boolean;
isInlineFragment: boolean;
isField: boolean;
isLeaf: boolean;
}
export interface SelectionSetInlineFragment extends SelectionSetItem {
selectionSet: SelectionSetItem[];
onType: string;
fields: SelectionSetFieldNode[];
fragmentsSpread: SelectionSetFragmentSpread[];
inlineFragments: SelectionSetInlineFragment[];
hasFragmentsSpread: boolean;
hasInlineFragments: boolean;
hasFields: boolean;
}
export interface SelectionSetFragmentSpread extends SelectionSetItem {
fragmentName: string;
}
export interface SelectionSetFieldNode extends SelectionSetItem {
selectionSet: SelectionSetItem[];
name: string;
type: string;
isRequired: boolean;
isArray: boolean;
fields: SelectionSetFieldNode[];
fragmentsSpread: SelectionSetFragmentSpread[];
inlineFragments: SelectionSetInlineFragment[];
hasFragmentsSpread: boolean;
hasInlineFragments: boolean;
hasFields: boolean;
}
export declare function isFieldNode(node: SelectionSetItem): node is SelectionSetFieldNode;
export declare function isFragmentSpreadNode(node: SelectionSetItem): node is SelectionSetFragmentSpread;
export declare function isInlineFragmentNode(node: SelectionSetItem): node is SelectionSetInlineFragment;
export interface Fragment {
name: string;
selectionSet: SelectionSetItem[];
onType: string;
}
export interface Operation {
name: string;
selectionSet: SelectionSetItem[];
operationType: string;
variables: Variable[];
hasVariables: boolean;
}
export interface Variable {
name: string;
type: string;
isRequired: boolean;
isArray: boolean;
}
export interface Document {
fragments: Fragment[];
operations: Operation[];
hasFragments: boolean;
hasOperations: boolean;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function isFieldNode(node) {
return node['name'] !== undefined && node['selectionSet'] !== undefined && node['type'] !== undefined;
}
exports.isFieldNode = isFieldNode;
function isFragmentSpreadNode(node) {
return node['fragmentName'] !== undefined;
}
exports.isFragmentSpreadNode = isFragmentSpreadNode;
function isInlineFragmentNode(node) {
return node['selectionSet'] !== undefined && node['onType'] !== undefined;
}
exports.isInlineFragmentNode = isInlineFragmentNode;
//# sourceMappingURL=types.js.map
{
"name": "graphql-codegen-core",
"version": "0.6.0-alpha.d381584b",
"version": "0.6.0-alpha.d5fe220f",
"description": "GraphQL types and code generator based on schema",
"main": "dist/index.js",
"scripts": {
"build-tests": "tsc -p tsconfig.test.json",
"watch": "tsc --watch",
"clean": "rimraf ./dist",

@@ -16,6 +14,2 @@ "lint": "tslint src/**/*.ts",

"debug": "cd dist && node --inspect --debug-brk gql-gen.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"create-git-tag": "git tag $(cat package.json | json version)",
"dev": "cd dist/cli && nodemon --ext ts,js,d.ts,template,graphql,json,handlebars gql-gen.js --dev --file ../../dev-test/githunt/schema.json --template ts --out ../../dev-test/githunt/typings.d.ts ../../dev-test/githunt/**/*.graphql",
"prepare--": "npm run build && npm run test && npm run create-git-tag && git push && git push --tags",
"test": "jest --no-cache --verbose --runInBand"

@@ -83,26 +77,10 @@ },

"dependencies": {
"camel-case": "^3.0.0",
"commander": "^2.10.0",
"common-tags": "^1.4.0",
"glob": "^7.1.2",
"graphql": "^0.10.3",
"graphql-tools": "^1.0.0",
"handlebars": "^4.0.10",
"mkdirp": "^0.5.1",
"pascal-case": "^2.0.1",
"request": "^2.81.0"
"graphql-tools": "^1.0.0"
},
"devDependencies": {
"@types/commander": "^2.9.1",
"@types/common-tags": "^1.2.5",
"@types/glob": "^5.0.30",
"@types/handlebars": "^4.0.33",
"@types/jest": "^20.0.2",
"@types/mkdirp": "^0.3.29",
"@types/node": "7",
"@types/request": "^0.0.44",
"conventional-changelog": "^1.1.3",
"cz-conventional-changelog": "^2.0.0",
"graphql-tag": "^2.4.2",
"jest": "^20.0.4",
"nodemon": "^1.11.0",
"rimraf": "^2.6.1",

@@ -109,0 +87,0 @@ "tslint": "^5.4.3",

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

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