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.19.0-alpha.2249ff45 to 0.19.0-alpha.22df701b

4

dist/schema/schema-to-template-context.d.ts
import { GraphQLSchema } from 'graphql';
import { SchemaTemplateContext } from '../types';
export declare function schemaToTemplateContext(schema: GraphQLSchema): SchemaTemplateContext;
import { SchemaTemplateContext, DocumentFile } from '../types';
export declare function schemaToTemplateContext(schema: GraphQLSchema, documents?: DocumentFile[]): SchemaTemplateContext;

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

var GRAPHQL_PRIMITIVES = ['String', 'Int', 'Boolean', 'ID', 'Float'];
var clearTypes = function (typesMap) {
var clearTypes = function (typesMap, forcedTypes) {
return Object.keys(typesMap)
.filter(function (key) { return !GRAPHQL_PRIMITIVES.includes(key) && !key.startsWith('__'); })
.filter(function (key) { return forcedTypes.includes(key) || (!GRAPHQL_PRIMITIVES.includes(key) && !key.startsWith('__')); })
.reduce(function (obj, key) {

@@ -23,4 +23,5 @@ obj[key] = typesMap[key];

};
function schemaToTemplateContext(schema) {
function schemaToTemplateContext(schema, documents) {
debugging_1.debugLog('[schemaToTemplateContext] started...');
var introspectionTypesToInclude = includeIntrospectionTypes(schema, documents);
var directives = graphql_toolkit_1.getDirectives(schema, schema);

@@ -48,3 +49,3 @@ var result = {

var rawTypesMap = schema.getTypeMap();
var typesMap = clearTypes(rawTypesMap);
var typesMap = clearTypes(rawTypesMap, introspectionTypesToInclude.map(function (t) { return t.name; }));
var typesArray = object_map_to_array_1.objectMapToArray(typesMap);

@@ -89,2 +90,18 @@ debugging_1.debugLog("[schemaToTemplateContext] Got total of " + typesArray.length + " types in the GraphQL schema");

exports.schemaToTemplateContext = schemaToTemplateContext;
function includeIntrospectionTypes(schema, documents) {
var typesToInclude = [];
if (documents) {
var typeInfo_1 = new graphql_1.TypeInfo(schema);
var visitor_1 = graphql_1.visitWithTypeInfo(typeInfo_1, {
Field: function () {
var type = graphql_1.getNamedType(typeInfo_1.getType());
if (graphql_1.isIntrospectionType(type) && graphql_1.isEnumType(type) && !typesToInclude.includes(type)) {
typesToInclude.push(type);
}
}
});
documents.forEach(function (doc) { return graphql_1.visit(doc.content, visitor_1); });
}
return typesToInclude;
}
//# sourceMappingURL=schema-to-template-context.js.map
{
"name": "graphql-codegen-core",
"version": "0.19.0-alpha.2249ff45",
"version": "0.19.0-alpha.22df701b",
"description": "GraphQL types and code generator based on schema",

@@ -18,3 +18,3 @@ "main": "dist/index.js",

"type": "git",
"url": "git+https://github.com/dotansimha/graphql-codegen.git"
"url": "git+https://github.com/dotansimha/graphql-code-generator.git"
},

@@ -68,3 +68,3 @@ "keywords": [

"graphql-tag": "2.10.1",
"graphql-toolkit": "0.2.0",
"graphql-toolkit": "0.2.5",
"graphql-tools": "4.0.4",

@@ -71,0 +71,0 @@ "ts-log": "2.1.4",

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