Socket
Socket
Sign inDemoInstall

graphql-codegen-compiler

Package Overview
Dependencies
Maintainers
1
Versions
408
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-codegen-compiler - npm Package Compare versions

Comparing version 0.9.0-alpha.465f2525 to 0.9.0-alpha.4ef2ace9

4

dist/field-type-to-string.d.ts

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

import { Argument, Field } from 'graphql-codegen-core';
export declare function getFieldTypeAsString(field: Field | Argument): string;
import { Argument, Field, Variable } from 'graphql-codegen-core';
export declare function getFieldTypeAsString(field: Field | Argument | Variable): string;

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

var compilationContext = splitted[splitted.length - 2];
var fileExtension = splitted[splitted.length - 3];
var base = splitted[splitted.length - 3].split('/');
var fileExtension = base[base.length - 1];
var handler = handlersMap[compilationContext];

@@ -134,0 +135,0 @@ if (handler) {

@@ -51,22 +51,25 @@ "use strict";

// Interface, input types, types
if (context.fields) {
if (context.fields && !context.onType && !context.operationType) {
context.fields.forEach(function (field) {
if (!config.primitives[field.type]) {
if (field.type === context.name) {
return;
}
var fieldType = field_type_to_string_1.getFieldTypeAsString(field);
var file = sanitizie_filename_1.sanitizeFilename(field.type, fieldType) + '.' + config.filesExtension;
var file = sanitizie_filename_1.sanitizeFilename(field.type, fieldType);
if (!imports.find(function (t) { return t.name === field.type; })) {
imports.push({ name: field.type, file: file });
}
// Fields arguments
if (field.arguments && field.arguments.length > 0) {
field.arguments.forEach(function (arg) {
if (!config.primitives[arg.type]) {
var fieldType_1 = field_type_to_string_1.getFieldTypeAsString(arg);
var file_1 = sanitizie_filename_1.sanitizeFilename(arg.type, fieldType_1) + '.' + config.filesExtension;
if (!imports.find(function (t) { return t.name === arg.type; })) {
imports.push({ name: arg.type, file: file_1 });
}
}
// Fields arguments
if (field.arguments && field.hasArguments) {
field.arguments.forEach(function (arg) {
if (!config.primitives[arg.type]) {
var fieldType = field_type_to_string_1.getFieldTypeAsString(arg);
var file = sanitizie_filename_1.sanitizeFilename(arg.type, fieldType);
if (!imports.find(function (t) { return t.name === arg.type; })) {
imports.push({ name: arg.type, file: file });
}
});
}
}
});
}

@@ -78,3 +81,3 @@ });

context.interfaces.forEach(function (infName) {
var file = sanitizie_filename_1.sanitizeFilename(infName, 'interface') + '.' + config.filesExtension;
var file = sanitizie_filename_1.sanitizeFilename(infName, 'interface');
if (!imports.find(function (t) { return t.name === infName; })) {

@@ -88,3 +91,3 @@ imports.push({ name: infName, file: file });

context.possibleTypes.forEach(function (possibleType) {
var file = sanitizie_filename_1.sanitizeFilename(possibleType, 'type') + '.' + config.filesExtension;
var file = sanitizie_filename_1.sanitizeFilename(possibleType, 'type');
if (!imports.find(function (t) { return t.name === possibleType; })) {

@@ -95,2 +98,13 @@ imports.push({ name: possibleType, file: file });

}
if (context.variables) {
context.variables.forEach(function (variable) {
if (!config.primitives[variable.type]) {
var fieldType = field_type_to_string_1.getFieldTypeAsString(variable);
var file = sanitizie_filename_1.sanitizeFilename(variable.type, fieldType);
if (!imports.find(function (t) { return t.name === variable.type; })) {
imports.push({ name: variable.type, file: file });
}
}
});
}
// Operations and Fragments

@@ -102,3 +116,3 @@ if (context.selectionSet) {

innerModel.fragmentsSpread.forEach(function (fragmentSpread) {
var file = sanitizie_filename_1.sanitizeFilename(fragmentSpread.fragmentName, 'fragment') + '.' + config.filesExtension;
var file = sanitizie_filename_1.sanitizeFilename(fragmentSpread.fragmentName, 'fragment');
if (!imports.find(function (t) { return t.name === fragmentSpread.fragmentName; })) {

@@ -109,31 +123,30 @@ imports.push({ name: fragmentSpread.fragmentName, file: file });

}
var schemaType = innerModel.schemaBaseType;
var inputType = schemaContext.inputTypes.find(function (inputType) { return inputType.name === schemaType; });
if (inputType) {
var file = sanitizie_filename_1.sanitizeFilename(inputType.name, 'input-type') + '.' + config.filesExtension;
if (!imports.find(function (t) { return t.name === inputType.name; })) {
imports.push({ name: inputType.name, file: file });
innerModel.fields.forEach(function (field) {
if (!config.primitives[field.type]) {
var type = null;
if (field.isEnum) {
type = 'enum';
}
else if (field.isInputType) {
type = 'input-type';
}
else if (field.isScalar) {
type = 'scalar';
}
if (type !== null) {
var file = sanitizie_filename_1.sanitizeFilename(field.type, type);
if (!imports.find(function (t) { return t.name === field.type; })) {
imports.push({ name: field.type, file: file });
}
}
}
return;
}
var enumType = schemaContext.enums.find(function (enumType) { return enumType.name === schemaType; });
if (enumType) {
var file = sanitizie_filename_1.sanitizeFilename(enumType.name, 'enum') + '.' + config.filesExtension;
if (!imports.find(function (t) { return t.name === enumType.name; })) {
imports.push({ name: enumType.name, file: file });
}
return;
}
var scalarType = schemaContext.scalars.find(function (scalarType) { return scalarType.name === schemaType; });
if (scalarType) {
var file = sanitizie_filename_1.sanitizeFilename(scalarType.name, 'scalar') + '.' + config.filesExtension;
if (!imports.find(function (t) { return t.name === scalarType.name; })) {
imports.push({ name: scalarType.name, file: file });
}
return;
}
});
});
}
for (var i = 0, j = imports.length; i < j; i++) {
ret = ret + options.fn(imports[i]);
ret = ret + options.fn(imports[i], {
data: {
withExtension: imports[i] + '.' + config.filesExtension,
},
});
}

@@ -140,0 +153,0 @@ return ret;

{
"name": "graphql-codegen-compiler",
"version": "0.9.0-alpha.465f2525",
"version": "0.9.0-alpha.4ef2ace9",
"description": "GraphQL code generator compiler",

@@ -28,5 +28,5 @@ "license": "MIT",

"common-tags": "^1.4.0",
"graphql-codegen-compiler": "^0.9.0-alpha.465f2525",
"graphql-codegen-core": "^0.9.0-alpha.465f2525",
"graphql-codegen-generators": "^0.9.0-alpha.465f2525",
"graphql-codegen-compiler": "0.9.0-alpha.4ef2ace9",
"graphql-codegen-core": "0.9.0-alpha.4ef2ace9",
"graphql-codegen-generators": "0.9.0-alpha.4ef2ace9",
"handlebars": "^4.0.10"

@@ -33,0 +33,0 @@ },

@@ -102,2 +102,13 @@ # `graphql-codegen-compiler`

### `eachImport(element: any)`
Iterates over a calculated array of imports (file names) that in use by the `element`.
Example:
```handlebars
{{#eachImport type}}
import { {{ name }} } from './{{file}}';
{{/eachImport}}
```
## Other Template Helpers

@@ -104,0 +115,0 @@

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