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

graphql-codegen-typescript

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-codegen-typescript - npm Package Compare versions

Comparing version 0.19.0-alpha.b268f76e to 0.19.0-alpha.b76e699a

dist/introspection-visitor.d.ts

40

dist/index.js

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

var visitor_1 = require("./visitor");
var introspection_visitor_1 = require("./introspection-visitor");
__export(require("./typescript-variables-to-object"));

@@ -16,4 +17,41 @@ exports.plugin = function (schema, documents, config) {

var visitorResult = graphql_1.visit(astNode, { leave: visitor });
return [header].concat(visitorResult.definitions).join('\n');
var introspectionDefinitions = includeIntrospectionDefinitions(schema, documents, config);
return [header].concat(visitorResult.definitions, introspectionDefinitions).join('\n');
};
function includeIntrospectionDefinitions(schema, documents, config) {
var typeInfo = new graphql_1.TypeInfo(schema);
var usedTypes = [];
var documentsVisitor = graphql_1.visitWithTypeInfo(typeInfo, {
Field: function () {
var type = graphql_1.getNamedType(typeInfo.getType());
if (graphql_1.isIntrospectionType(type) && !usedTypes.includes(type)) {
usedTypes.push(type);
}
}
});
documents.forEach(function (doc) { return graphql_1.visit(doc.content, documentsVisitor); });
var typesToInclude = [];
usedTypes.forEach(function (type) {
collectTypes(type);
});
var visitor = new introspection_visitor_1.TsIntrospectionVisitor(config, typesToInclude);
var result = graphql_1.visit(graphql_1.parse(graphql_1.printIntrospectionSchema(schema)), { leave: visitor });
// recursively go through each `usedTypes` and their children and collect all used types
// we don't care about Interfaces, Unions and others, but Objects and Enums
function collectTypes(type) {
if (typesToInclude.includes(type)) {
return;
}
typesToInclude.push(type);
if (graphql_1.isObjectType(type)) {
var fields_1 = type.getFields();
Object.keys(fields_1).forEach(function (key) {
var field = fields_1[key];
var type = graphql_1.getNamedType(field.type);
collectTypes(type);
});
}
}
return result.definitions;
}
//# sourceMappingURL=index.js.map

8

package.json
{
"name": "graphql-codegen-typescript",
"version": "0.19.0-alpha.b268f76e",
"version": "0.19.0-alpha.b76e699a",
"description": "GraphQL Code Generator plugin for generating TypeScript types",

@@ -14,5 +14,5 @@ "repository": "git@github.com:dotansimha/graphql-code-generator.git",

"dependencies": {
"graphql-codegen-core": "0.19.0-alpha.b268f76e",
"graphql-codegen-plugin-helpers": "0.19.0-alpha.b268f76e",
"graphql-codegen-visitor-plugin-common": "0.19.0-alpha.b268f76e"
"graphql-codegen-core": "0.19.0-alpha.b76e699a",
"graphql-codegen-plugin-helpers": "0.19.0-alpha.b76e699a",
"graphql-codegen-visitor-plugin-common": "0.19.0-alpha.b76e699a"
},

@@ -19,0 +19,0 @@ "devDependencies": {

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