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.8.0-alpha.c833ee09 to 0.8.0

dist/schema/transform-directives.d.ts

4

dist/operations/transform-fragment-document.js

@@ -7,2 +7,3 @@ "use strict";

var printer_1 = require("graphql/language/printer");
var get_directives_1 = require("../utils/get-directives");
function transformFragment(schema, fragment) {

@@ -13,2 +14,3 @@ debugging_1.debugLog("[transformFragment] transforming fragment " + fragment.name.value + " on type " + fragment.typeCondition.name.value);

var onType = fragment.typeCondition.name.value;
var directives = get_directives_1.getDirectives(schema, fragment);
return {

@@ -19,2 +21,4 @@ name: name,

document: printer_1.print(fragment),
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -21,0 +25,0 @@ }

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

var printer_1 = require("graphql/language/printer");
var get_directives_1 = require("../utils/get-directives");
function transformOperation(schema, operationNode) {

@@ -14,2 +15,3 @@ var name = operationNode.name && operationNode.name.value ? operationNode.name.value : '';

var variables = transform_variables_1.transformVariables(schema, operationNode);
var directives = get_directives_1.getDirectives(schema, operationNode);
return {

@@ -25,2 +27,4 @@ name: name,

document: printer_1.print(operationNode),
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -27,0 +31,0 @@ }

2

dist/schema/resolve-arguments.d.ts
import { GraphQLArgument } from 'graphql';
import { Argument } from '../types';
export declare function resolveArguments(args: GraphQLArgument[]): Argument[];
export declare function resolveArguments(schema: any, args: GraphQLArgument[]): Argument[];

@@ -7,3 +7,4 @@ "use strict";

var debugging_1 = require("../debugging");
function resolveArguments(args) {
var get_directives_1 = require("../utils/get-directives");
function resolveArguments(schema, args) {
return args.map(function (arg) {

@@ -13,2 +14,3 @@ var type = resolve_type_1.resolveType(arg.type);

var indicators = resolve_type_indicators_1.resolveTypeIndicators(namedType);
var directives = get_directives_1.getDirectives(schema, arg);
debugging_1.debugLog("[resolveArguments] resolving argument " + arg.name + " of type " + type.name + "...");

@@ -27,2 +29,4 @@ return {

isType: indicators.isType,
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -29,0 +33,0 @@ });

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

var debugging_1 = require("../debugging");
var transform_directives_1 = require("./transform-directives");
var get_directives_1 = require("../utils/get-directives");
var GRAPHQL_PRIMITIVES = ['String', 'Int', 'Boolean', 'ID', 'Float'];

@@ -21,2 +23,3 @@ var clearTypes = function (typesMap) { return Object.keys(typesMap)

debugging_1.debugLog('[schemaToTemplateContext] started...');
var directives = get_directives_1.getDirectives(schema, schema);
var result = {

@@ -29,2 +32,4 @@ types: [],

interfaces: [],
definedDirectives: [],
// Indicators
hasTypes: false,

@@ -36,2 +41,6 @@ hasInputTypes: false,

hasInterfaces: false,
hasDefinedDirectives: false,
rawSchema: schema,
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -45,18 +54,18 @@ var rawTypesMap = schema.getTypeMap();

if (actualTypeDef instanceof graphql_1.GraphQLObjectType) {
result.types.push(transform_object_1.transformGraphQLObject(actualTypeDef));
result.types.push(transform_object_1.transformGraphQLObject(schema, actualTypeDef));
}
else if (actualTypeDef instanceof graphql_1.GraphQLInputObjectType) {
result.inputTypes.push(transform_object_1.transformGraphQLObject(actualTypeDef));
result.inputTypes.push(transform_object_1.transformGraphQLObject(schema, actualTypeDef));
}
else if (actualTypeDef instanceof graphql_1.GraphQLEnumType) {
result.enums.push(transform_enum_1.transformGraphQLEnum(actualTypeDef));
result.enums.push(transform_enum_1.transformGraphQLEnum(schema, actualTypeDef));
}
else if (actualTypeDef instanceof graphql_1.GraphQLUnionType) {
result.unions.push(transform_union_1.transformUnion(actualTypeDef));
result.unions.push(transform_union_1.transformUnion(schema, actualTypeDef));
}
else if (actualTypeDef instanceof graphql_1.GraphQLInterfaceType) {
result.interfaces.push(transform_interface_1.transformInterface(actualTypeDef));
result.interfaces.push(transform_interface_1.transformInterface(schema, actualTypeDef));
}
else if (actualTypeDef instanceof graphql_1.GraphQLScalarType) {
result.scalars.push(transform_scalar_1.transformScalar(actualTypeDef));
result.scalars.push(transform_scalar_1.transformScalar(schema, actualTypeDef));
}

@@ -67,2 +76,3 @@ else {

});
result.definedDirectives = transform_directives_1.transformDirectives(schema, schema.getDirectives() || []);
result.hasTypes = result.types.length > 0;

@@ -74,2 +84,3 @@ result.hasInputTypes = result.inputTypes.length > 0;

result.hasInterfaces = result.interfaces.length > 0;
result.hasDefinedDirectives = result.definedDirectives.length > 0;
debugging_1.debugLog("[schemaToTemplateContext] done, results is: ", result);

@@ -76,0 +87,0 @@ return result;

@@ -1,3 +0,3 @@

import { GraphQLEnumType } from 'graphql';
import { GraphQLEnumType, GraphQLSchema } from 'graphql';
import { Enum } from '../types';
export declare function transformGraphQLEnum(graphqlEnum: GraphQLEnumType): Enum;
export declare function transformGraphQLEnum(schema: GraphQLSchema, graphqlEnum: GraphQLEnumType): Enum;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var debugging_1 = require("../debugging");
function transformGraphQLEnum(graphqlEnum) {
var get_directives_1 = require("../utils/get-directives");
function transformGraphQLEnum(schema, graphqlEnum) {
debugging_1.debugLog("[transformGraphQLEnum] transformed enum " + graphqlEnum.name);
var directives = get_directives_1.getDirectives(schema, graphqlEnum);
var enumValues = graphqlEnum.getValues().map(function (enumItem) {

@@ -17,2 +19,4 @@ return {

values: enumValues,
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -19,0 +23,0 @@ }

@@ -1,3 +0,3 @@

import { GraphQLFieldMap } from 'graphql';
import { GraphQLFieldMap, GraphQLSchema } from 'graphql';
import { Field } from '../types';
export declare function resolveFields(rawFields: GraphQLFieldMap<any, any>): Field[];
export declare function resolveFields(schema: GraphQLSchema, rawFields: GraphQLFieldMap<any, any>): Field[];

@@ -9,9 +9,11 @@ "use strict";

var debugging_1 = require("../debugging");
function resolveFields(rawFields) {
var get_directives_1 = require("../utils/get-directives");
function resolveFields(schema, rawFields) {
var fieldsArray = object_map_to_array_1.objectMapToArray(rawFields);
return fieldsArray.map(function (item) {
var type = resolve_type_1.resolveType(item.value.type);
var resolvedArguments = resolve_arguments_1.resolveArguments(item.value.args || []);
var resolvedArguments = resolve_arguments_1.resolveArguments(schema, item.value.args || []);
var namedType = graphql_1.getNamedType(item.value.type);
var indicators = resolve_type_indicators_1.resolveTypeIndicators(namedType);
var directives = get_directives_1.getDirectives(schema, item.value);
debugging_1.debugLog("[resolveFields] transformed field " + item.value.name + " of type " + type + ", resolved type is: ", type);

@@ -32,2 +34,4 @@ return {

isType: indicators.isType,
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -34,0 +38,0 @@ });

@@ -1,3 +0,3 @@

import { GraphQLInterfaceType } from 'graphql';
import { GraphQLInterfaceType, GraphQLSchema } from 'graphql';
import { Interface } from '../types';
export declare function transformInterface(gqlInterface: GraphQLInterfaceType): Interface;
export declare function transformInterface(schema: GraphQLSchema, gqlInterface: GraphQLInterfaceType): Interface;

@@ -5,5 +5,7 @@ "use strict";

var debugging_1 = require("../debugging");
function transformInterface(gqlInterface) {
var get_directives_1 = require("../utils/get-directives");
function transformInterface(schema, gqlInterface) {
debugging_1.debugLog("[transformInterface] transformed interface " + gqlInterface.name);
var resolvedFields = transform_fields_1.resolveFields(gqlInterface.getFields());
var resolvedFields = transform_fields_1.resolveFields(schema, gqlInterface.getFields());
var directives = get_directives_1.getDirectives(schema, gqlInterface);
return {

@@ -14,2 +16,4 @@ name: gqlInterface.name,

hasFields: resolvedFields.length > 0,
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -16,0 +20,0 @@ }

@@ -1,3 +0,3 @@

import { GraphQLInputObjectType, GraphQLObjectType } from 'graphql';
import { GraphQLInputObjectType, GraphQLObjectType, GraphQLSchema } from 'graphql';
import { Type } from '../types';
export declare function transformGraphQLObject(object: GraphQLObjectType | GraphQLInputObjectType): Type;
export declare function transformGraphQLObject(schema: GraphQLSchema, object: GraphQLObjectType | GraphQLInputObjectType): Type;

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

var debugging_1 = require("../debugging");
function transformGraphQLObject(object) {
var get_directives_1 = require("../utils/get-directives");
function transformGraphQLObject(schema, object) {
debugging_1.debugLog("[transformGraphQLObject] transforming type " + object.name);
var resolvedFields = transform_fields_1.resolveFields(object.getFields());
var resolvedFields = transform_fields_1.resolveFields(schema, object.getFields());
var resolvedInterfaces = object instanceof graphql_1.GraphQLObjectType ? object.getInterfaces().map(function (inf) { return inf.name; }) : [];
var directives = get_directives_1.getDirectives(schema, object);
return {

@@ -19,2 +21,4 @@ name: object.name,

hasInterfaces: resolvedInterfaces.length > 0,
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -21,0 +25,0 @@ }

@@ -1,3 +0,3 @@

import { GraphQLScalarType } from 'graphql';
import { GraphQLScalarType, GraphQLSchema } from 'graphql';
import { Scalar } from '../types';
export declare function transformScalar(scalar: GraphQLScalarType): Scalar;
export declare function transformScalar(schema: GraphQLSchema, scalar: GraphQLScalarType): Scalar;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var debugging_1 = require("../debugging");
function transformScalar(scalar) {
var get_directives_1 = require("../utils/get-directives");
function transformScalar(schema, scalar) {
debugging_1.debugLog("[transformInterface] transformed custom scalar " + scalar.name);
var directives = get_directives_1.getDirectives(schema, scalar);
return {
name: scalar.name,
description: scalar.description || '',
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -10,0 +14,0 @@ }

@@ -1,3 +0,3 @@

import { GraphQLUnionType } from 'graphql';
import { GraphQLSchema, GraphQLUnionType } from 'graphql';
import { Union } from '../types';
export declare function transformUnion(union: GraphQLUnionType): Union;
export declare function transformUnion(schema: GraphQLSchema, union: GraphQLUnionType): Union;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var debugging_1 = require("../debugging");
function transformUnion(union) {
var get_directives_1 = require("../utils/get-directives");
function transformUnion(schema, union) {
debugging_1.debugLog("[transformUnion] transformed union " + union.name);
var directives = get_directives_1.getDirectives(schema, union);
return {

@@ -10,2 +12,4 @@ name: union.name,

possibleTypes: union.getTypes().map(function (type) { return type.name; }),
directives: directives,
usesDirectives: Object.keys(directives).length > 0,
};

@@ -12,0 +16,0 @@ }

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

export interface Argument {
import { GraphQLSchema } from 'graphql';
export interface AstNode {
directives: DirectiveUseMap;
usesDirectives: boolean;
}
export interface Argument extends AstNode {
name: string;

@@ -14,3 +19,3 @@ description: string;

}
export interface Field {
export interface Field extends AstNode {
name: string;

@@ -30,3 +35,3 @@ description: string;

}
export interface Type {
export interface Type extends AstNode {
fields: Field[];

@@ -40,7 +45,7 @@ description: string;

}
export interface Scalar {
export interface Scalar extends AstNode {
name: string;
description: string;
}
export interface Enum {
export interface Enum extends AstNode {
name: string;

@@ -50,3 +55,3 @@ description: string;

}
export interface EnumValue {
export interface EnumValue extends AstNode {
name: string;

@@ -56,3 +61,3 @@ value: string;

}
export interface Union {
export interface Union extends AstNode {
name: string;

@@ -62,3 +67,3 @@ description: string;

}
export interface Interface {
export interface Interface extends AstNode {
name: string;

@@ -69,3 +74,3 @@ description: string;

}
export interface SchemaTemplateContext {
export interface SchemaTemplateContext extends AstNode {
types: Type[];

@@ -77,2 +82,3 @@ inputTypes: Type[];

scalars: Scalar[];
definedDirectives: Directive[];
hasTypes: boolean;

@@ -84,4 +90,6 @@ hasInputTypes: boolean;

hasInterfaces: boolean;
hasDefinedDirectives: boolean;
rawSchema: GraphQLSchema;
}
export interface SelectionSetItem {
export interface SelectionSetItem extends AstNode {
isFragmentSpread: boolean;

@@ -121,3 +129,3 @@ isInlineFragment: boolean;

export declare function isInlineFragmentNode(node: SelectionSetItem): node is SelectionSetInlineFragment;
export interface Fragment {
export interface Fragment extends AstNode {
name: string;

@@ -128,3 +136,3 @@ selectionSet: SelectionSetItem[];

}
export interface Operation {
export interface Operation extends AstNode {
name: string;

@@ -152,1 +160,29 @@ selectionSet: SelectionSetItem[];

}
export interface DirectiveUseMap {
[name: string]: string;
}
export interface Directive {
name: string;
description: string;
locations: string[];
arguments: Argument[];
hasArguments: boolean;
onFragmentSpread: boolean;
onInlineFragment: boolean;
onQuery: boolean;
onMutation: boolean;
onSubscription: boolean;
onFragment: boolean;
onField: boolean;
onSchema: boolean;
onScalar: boolean;
onFieldDefinition: boolean;
onEnum: boolean;
onEnumValue: boolean;
onObject: boolean;
onInputObject: boolean;
onInputField: boolean;
onArgument: boolean;
onInterface: boolean;
onUnion: boolean;
}
{
"name": "graphql-codegen-core",
"version": "0.8.0-alpha.c833ee09",
"version": "0.8.0",
"description": "GraphQL types and code generator based on schema",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -17,4 +17,4 @@ {

"declaration": true,
"outDir": "./dist",
"rootDir": "./src"
"outDir": "./dist/",
"rootDir": "./src/"
},

@@ -21,0 +21,0 @@ "files": [

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

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