graphql-codegen-core
Advanced tools
Comparing version 0.6.0-alpha.8a5e7815 to 0.6.0-alpha.8e61e231
@@ -5,1 +5,2 @@ export { schemaToTemplateContext } from './schema/schema-to-template-context'; | ||
export { Argument, Field, Type, Scalar, Enum, EnumValue, Union, Interface, SchemaTemplateContext, Document, Variable, Operation, Fragment, SelectionSetItem, SelectionSetFieldNode, SelectionSetFragmentSpread, SelectionSetInlineFragment, isFieldNode, isFragmentSpreadNode, isInlineFragmentNode } from './types'; | ||
export { debugLog } from './debugging'; |
@@ -14,2 +14,4 @@ "use strict"; | ||
exports.isInlineFragmentNode = types_1.isInlineFragmentNode; | ||
var debugging_1 = require("./debugging"); | ||
exports.debugLog = debugging_1.debugLog; | ||
//# sourceMappingURL=index.js.map |
@@ -16,2 +16,3 @@ "use strict"; | ||
var resolve_type_1 = require("../schema/resolve-type"); | ||
var debugging_1 = require("../debugging"); | ||
function separateSelectionSet(selectionSet) { | ||
@@ -34,9 +35,12 @@ var fields = selectionSet.filter(function (n) { return types_1.isFieldNode(n); }); | ||
var fieldNode = selectionNode; | ||
var name = fieldNode.alias && fieldNode.alias.value ? fieldNode.alias.value : fieldNode.name.value; | ||
debugging_1.debugLog("[buildSelectionSet] transforming FIELD with name " + name); | ||
var field = get_field_def_1.getFieldDef(rootObject, fieldNode); | ||
var resolvedType = resolve_type_1.resolveType(field.type); | ||
var childSelectionSet = buildSelectionSet(schema, graphql_1.getNamedType(field.type), fieldNode.selectionSet); | ||
return __assign({ isField: true, isFragmentSpread: false, isInlineFragment: false, isLeaf: childSelectionSet.length === 0, name: fieldNode.alias && fieldNode.alias.value ? fieldNode.alias.value : fieldNode.name.value, selectionSet: childSelectionSet }, separateSelectionSet(childSelectionSet), { type: resolvedType.name, isRequired: resolvedType.isRequired, isArray: resolvedType.isArray }); | ||
return __assign({ isField: true, isFragmentSpread: false, isInlineFragment: false, isLeaf: childSelectionSet.length === 0, name: name, selectionSet: childSelectionSet }, separateSelectionSet(childSelectionSet), { type: resolvedType.name, isRequired: resolvedType.isRequired, isArray: resolvedType.isArray }); | ||
} | ||
else if (selectionNode.kind === kinds_1.FRAGMENT_SPREAD) { | ||
var fieldNode = selectionNode; | ||
debugging_1.debugLog("[buildSelectionSet] transforming FRAGMENT_SPREAD with name " + fieldNode.name.value + "..."); | ||
return { | ||
@@ -51,2 +55,3 @@ isField: false, | ||
else if (selectionNode.kind === kinds_1.INLINE_FRAGMENT) { | ||
debugging_1.debugLog("[buildSelectionSet] transforming INLINE_FRAGMENT..."); | ||
var fieldNode = selectionNode; | ||
@@ -53,0 +58,0 @@ var nextRoot = graphql_1.typeFromAST(schema, fieldNode.typeCondition); |
@@ -6,2 +6,3 @@ "use strict"; | ||
var transform_operation_1 = require("./transform-operation"); | ||
var debugging_1 = require("../debugging"); | ||
function transformDocument(schema, documentNode) { | ||
@@ -14,3 +15,5 @@ var result = { | ||
}; | ||
(documentNode.definitions || []).forEach(function (definitionNode) { | ||
var definitions = (documentNode.definitions || []); | ||
debugging_1.debugLog("[transformDocument] transforming total of " + definitions.length + " definitions..."); | ||
definitions.forEach(function (definitionNode) { | ||
if (definitionNode.kind === kinds_1.OPERATION_DEFINITION) { | ||
@@ -17,0 +20,0 @@ result.operations.push(transform_operation_1.transformOperation(schema, definitionNode)); |
@@ -5,3 +5,5 @@ "use strict"; | ||
var build_selection_set_1 = require("./build-selection-set"); | ||
var debugging_1 = require("../debugging"); | ||
function transformFragment(schema, fragment) { | ||
debugging_1.debugLog("[transformFragment] transforming fragment " + fragment.name.value + " on type " + fragment.typeCondition.name.value); | ||
var root = graphql_1.typeFromAST(schema, fragment.typeCondition); | ||
@@ -8,0 +10,0 @@ var name = fragment.name.value; |
@@ -6,7 +6,10 @@ "use strict"; | ||
var transform_variables_1 = require("./transform-variables"); | ||
var debugging_1 = require("../debugging"); | ||
function transformOperation(schema, operationNode) { | ||
var name = operationNode.name && operationNode.name.value ? operationNode.name.value : ''; | ||
debugging_1.debugLog("[transformOperation] transforming operation " + name + " of type " + operationNode.operation); | ||
var root = get_root_1.getRoot(schema, operationNode); | ||
var variables = transform_variables_1.transformVariables(schema, operationNode); | ||
return { | ||
name: operationNode.name && operationNode.name.value ? operationNode.name.value : '', | ||
name: name, | ||
selectionSet: build_selection_set_1.buildSelectionSet(schema, root, operationNode.selectionSet), | ||
@@ -13,0 +16,0 @@ operationType: operationNode.operation, |
@@ -5,2 +5,3 @@ "use strict"; | ||
var resolve_type_1 = require("../schema/resolve-type"); | ||
var debugging_1 = require("../debugging"); | ||
function transformVariables(schema, definitionNode) { | ||
@@ -10,2 +11,3 @@ return definitionNode.variableDefinitions.map(function (variableDefinition) { | ||
var resolvedType = resolve_type_1.resolveType(typeFromSchema); | ||
debugging_1.debugLog("[transformVariables] transforming variable " + variableDefinition.variable.name.value + " of type " + resolvedType.name); | ||
return { | ||
@@ -12,0 +14,0 @@ name: variableDefinition.variable.name.value, |
@@ -6,2 +6,3 @@ "use strict"; | ||
var resolve_type_indicators_1 = require("./resolve-type-indicators"); | ||
var debugging_1 = require("../debugging"); | ||
function resolveArguments(args) { | ||
@@ -12,2 +13,3 @@ return args.map(function (arg) { | ||
var indicators = resolve_type_indicators_1.resolveTypeIndicators(namedType); | ||
debugging_1.debugLog("[resolveArguments] resolving argument " + arg.name + " of type " + type.name + "..."); | ||
return { | ||
@@ -14,0 +16,0 @@ name: arg.name, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var graphql_1 = require("graphql"); | ||
var debugging_1 = require("../debugging"); | ||
function isRequired(type) { | ||
@@ -13,4 +14,6 @@ return (String(type)).indexOf('!') > -1; | ||
function resolveType(type) { | ||
var name = graphql_1.getNamedType(type).name; | ||
debugging_1.debugLog("[resolveType] resolving type " + name); | ||
return { | ||
name: graphql_1.getNamedType(type).name, | ||
name: name, | ||
isRequired: isRequired(type), | ||
@@ -17,0 +20,0 @@ isArray: isArray(type), |
@@ -10,2 +10,3 @@ "use strict"; | ||
var transform_scalar_1 = require("./transform-scalar"); | ||
var debugging_1 = require("../debugging"); | ||
var GRAPHQL_PRIMITIVES = ['String', 'Int', 'Boolean', 'ID', 'Float']; | ||
@@ -19,2 +20,3 @@ var clearTypes = function (typesMap) { return Object.keys(typesMap) | ||
function schemaToTemplateContext(schema) { | ||
debugging_1.debugLog('[schemaToTemplateContext] started...'); | ||
var result = { | ||
@@ -37,2 +39,3 @@ types: [], | ||
var typesArray = object_map_to_array_1.objectMapToArray(typesMap); | ||
debugging_1.debugLog("[schemaToTemplateContext] Got total of " + typesArray.length + " types in the GraphQL schema"); | ||
typesArray.map(function (graphQlType) { | ||
@@ -68,2 +71,3 @@ var actualTypeDef = graphQlType.value; | ||
result.hasInterfaces = result.interfaces.length > 0; | ||
debugging_1.debugLog("[schemaToTemplateContext] done, results is: ", result); | ||
return result; | ||
@@ -70,0 +74,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var debugging_1 = require("../debugging"); | ||
function transformGraphQLEnum(graphqlEnum) { | ||
debugging_1.debugLog("[transformGraphQLEnum] transformed enum " + graphqlEnum.name); | ||
var enumValues = graphqlEnum.getValues().map(function (enumItem) { | ||
@@ -5,0 +7,0 @@ return { |
@@ -8,2 +8,3 @@ "use strict"; | ||
var resolve_type_indicators_1 = require("./resolve-type-indicators"); | ||
var debugging_1 = require("../debugging"); | ||
function resolveFields(rawFields) { | ||
@@ -16,2 +17,3 @@ var fieldsArray = object_map_to_array_1.objectMapToArray(rawFields); | ||
var indicators = resolve_type_indicators_1.resolveTypeIndicators(namedType); | ||
debugging_1.debugLog("[resolveFields] transformed field " + item.value.name + " of type " + type + ", resolved type is: ", type); | ||
return { | ||
@@ -18,0 +20,0 @@ name: item.value.name, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var transform_fields_1 = require("./transform-fields"); | ||
var debugging_1 = require("../debugging"); | ||
function transformInterface(gqlInterface) { | ||
debugging_1.debugLog("[transformInterface] transformed interface " + gqlInterface.name); | ||
var resolvedFields = transform_fields_1.resolveFields(gqlInterface.getFields()); | ||
@@ -6,0 +8,0 @@ return { |
@@ -5,3 +5,5 @@ "use strict"; | ||
var transform_fields_1 = require("./transform-fields"); | ||
var debugging_1 = require("../debugging"); | ||
function transformGraphQLObject(object) { | ||
debugging_1.debugLog("[transformGraphQLObject] transforming type " + object.name); | ||
var resolvedFields = transform_fields_1.resolveFields(object.getFields()); | ||
@@ -8,0 +10,0 @@ var resolvedInterfaces = object instanceof graphql_1.GraphQLObjectType ? object.getInterfaces().map(function (inf) { return inf.name; }) : []; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var debugging_1 = require("../debugging"); | ||
function transformScalar(scalar) { | ||
debugging_1.debugLog("[transformInterface] transformed custom scalar " + scalar.name); | ||
return { | ||
@@ -5,0 +7,0 @@ name: scalar.name, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var debugging_1 = require("../debugging"); | ||
function transformUnion(union) { | ||
debugging_1.debugLog("[transformUnion] transformed union " + union.name); | ||
return { | ||
@@ -5,0 +7,0 @@ name: union.name, |
{ | ||
"name": "graphql-codegen-core", | ||
"version": "0.6.0-alpha.8a5e7815", | ||
"version": "0.6.0-alpha.8e61e231", | ||
"description": "GraphQL types and code generator based on schema", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
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
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
239814
72
784