gql-types-generator
Advanced tools
Comparing version 1.4.5 to 1.4.6
@@ -79,3 +79,3 @@ "use strict"; | ||
return misc_1.formatDescription(description) | ||
+ ("export namespace " + misc_1.toCamelCase(name) + " {\n") | ||
+ ("export namespace " + name + " {\n") | ||
+ misc_1.withSpaces(nspDefinition, 2) | ||
@@ -154,3 +154,3 @@ + "\n}\n\n" | ||
}, ''); | ||
result += "export namespace " + misc_1.toCamelCase(name) + " {\n" | ||
result += "export namespace " + name + " {\n" | ||
+ misc_1.withSpaces(content, 2) | ||
@@ -157,0 +157,0 @@ + '}\n'; |
@@ -76,4 +76,11 @@ import { Enum, Scalar, Union, Entity, PreparedObject, Operation, PreparedObjectField, OperationNamespaceField, OperationRootNamespace, NamedGQLType } from '../types'; | ||
export declare function getImportTypes(field: OperationNamespaceField): string[]; | ||
export declare function parseFieldNode(node: FieldNode, rootNode: GraphQLObjectType, prevPath: string): OperationNamespaceField; | ||
/** | ||
* Converts FieldNode to OperationNamespaceField | ||
* @param {FieldNode} node | ||
* @param {GraphQLObjectType} rootNode | ||
* @param {string} prevPath | ||
* @returns {OperationNamespaceField} | ||
*/ | ||
export declare function fieldNodeToNamespaceField(node: FieldNode, rootNode: GraphQLObjectType, prevPath: string): OperationNamespaceField; | ||
/** | ||
* Parses GQL operation | ||
@@ -80,0 +87,0 @@ * @param {OperationDefinitionNode} node |
@@ -233,5 +233,6 @@ "use strict"; | ||
if (s.kind === 'Field') { | ||
var name = s.name.value; | ||
acc.push({ | ||
name: s.name.value, | ||
type: nspName + "." + misc_1.toCamelCase(s.name.value), | ||
name: name, | ||
type: nspName + "." + name, | ||
}); | ||
@@ -255,3 +256,3 @@ } | ||
if (s.kind === 'Field') { | ||
acc.push(parseFieldNode(s, rootNode, path)); | ||
acc.push(fieldNodeToNamespaceField(s, rootNode, path)); | ||
} | ||
@@ -302,18 +303,24 @@ return acc; | ||
exports.getImportTypes = getImportTypes; | ||
function parseFieldNode(node, rootNode, prevPath) { | ||
var name = node.name.value; | ||
var compiledName = misc_1.toCamelCase(name); | ||
var path = prevPath.length > 0 ? prevPath + "." + name : name; | ||
/** | ||
* Converts FieldNode to OperationNamespaceField | ||
* @param {FieldNode} node | ||
* @param {GraphQLObjectType} rootNode | ||
* @param {string} prevPath | ||
* @returns {OperationNamespaceField} | ||
*/ | ||
function fieldNodeToNamespaceField(node, rootNode, prevPath) { | ||
var nodeName = node.name.value; | ||
var path = prevPath.length > 0 ? prevPath + "." + nodeName : nodeName; | ||
if (node.selectionSet) { | ||
return { | ||
name: compiledName, | ||
name: nodeName, | ||
type: { | ||
name: compiledName, | ||
name: nodeName, | ||
fields: node.selectionSet.selections.reduce(function (acc, s) { | ||
// TODO: Fragments support | ||
if (s.kind === 'Field') { | ||
var selectionCompiledName = misc_1.toCamelCase(s.name.value); | ||
var selectionName = s.name.value; | ||
acc.push({ | ||
name: s.name.value, | ||
type: compiledName + "." + selectionCompiledName, | ||
name: selectionName, | ||
type: nodeName + "." + selectionName, | ||
}); | ||
@@ -329,7 +336,7 @@ } | ||
return { | ||
name: compiledName, | ||
name: nodeName, | ||
type: misc_1.getIOTypeDefinition(type), | ||
}; | ||
} | ||
exports.parseFieldNode = parseFieldNode; | ||
exports.fieldNodeToNamespaceField = fieldNodeToNamespaceField; | ||
/** | ||
@@ -344,3 +351,3 @@ * Parses GQL operation | ||
var name = node.name, selectionSet = node.selectionSet, operation = node.operation, variableDefinitions = node.variableDefinitions, loc = node.loc; | ||
var compiledName = misc_1.getCompiledOperationName(name.value, operation); | ||
var operationName = misc_1.getCompiledOperationName(name.value, operation); | ||
var rootNode = misc_1.getOperationRootNode(schema, operation); | ||
@@ -355,4 +362,4 @@ var importTypes = []; | ||
var selection = { | ||
name: compiledName, | ||
fields: selectionSetToObjectFields(selectionSet, compiledName), | ||
name: operationName, | ||
fields: selectionSetToObjectFields(selectionSet, operationName), | ||
}; | ||
@@ -363,7 +370,7 @@ // Arguments | ||
// Namespace | ||
var namespace = selectionSetToRootNamespace(selectionSet, compiledName, args, rootNode); | ||
var namespace = selectionSetToRootNamespace(selectionSet, operationName, args, rootNode); | ||
addImportTypes(namespace.importTypes); | ||
return { | ||
__type: 'operation', | ||
name: name.value + misc_1.toCamelCase(operation), | ||
name: operationName, | ||
signature: operationsString.slice(loc.start, loc.end), | ||
@@ -370,0 +377,0 @@ selection: selection, |
{ | ||
"name": "gql-types-generator", | ||
"version": "1.4.5", | ||
"version": "1.4.6", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -198,3 +198,3 @@ gql-types-generator | ||
to get some `Query` field type you could use `Query['someField']` | ||
or `Query.SomeField`. They return the same thing. It is recommended | ||
or `Query.someField`. They return the same thing. It is recommended | ||
to use `Query.*`-like syntax for better experience. | ||
@@ -201,0 +201,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86002
1955