graphql-codegen-visitor-plugin-common
Advanced tools
Comparing version 0.19.0-alpha.d20bb04b to 0.19.0-alpha.d32dbce6
@@ -17,3 +17,3 @@ import { ScalarsMap, NamingConvention, ConvertFn, ConvertOptions } from './types'; | ||
typesPrefix: string; | ||
contextType: string; | ||
contextType: ParsedMapper; | ||
mappers: { | ||
@@ -20,0 +20,0 @@ [typeName: string]: ParsedMapper; |
@@ -15,3 +15,3 @@ "use strict"; | ||
this._collectedDirectiveResolvers = {}; | ||
this._parsedConfig = Object.assign({ scalars: Object.assign({}, (defaultScalars || scalars_1.DEFAULT_SCALARS), (rawConfig.scalars || {})), convert: naming_1.convertFactory(rawConfig), typesPrefix: rawConfig.typesPrefix || '', contextType: rawConfig.contextType || 'any', mappers: this.transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})); | ||
this._parsedConfig = Object.assign({ scalars: Object.assign({}, (defaultScalars || scalars_1.DEFAULT_SCALARS), (rawConfig.scalars || {})), convert: naming_1.convertFactory(rawConfig), typesPrefix: rawConfig.typesPrefix || '', contextType: this.parseMapper(rawConfig.contextType || 'any'), mappers: this.transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})); | ||
autoBind(this); | ||
@@ -66,2 +66,8 @@ this._variablesTransfomer = new variables_to_object_1.OperationVariablesToObject(this.scalars, this.convertName); | ||
}); | ||
if (this.config.contextType.isExternal) { | ||
if (!groupedMappers[this.config.contextType.source]) { | ||
groupedMappers[this.config.contextType.source] = []; | ||
} | ||
groupedMappers[this.config.contextType.source].push(this.config.contextType.type); | ||
} | ||
return Object.keys(groupedMappers).map(source => this.buildMapperImport(source, groupedMappers[source])); | ||
@@ -86,3 +92,3 @@ } | ||
.asKind('type') | ||
.withName(this.convertName('IResolvers'), `<Context = ${this.config.contextType}>`) | ||
.withName(this.convertName('IResolvers'), `<Context = ${this.config.contextType.type}>`) | ||
.withBlock(Object.keys(this._collectedResolvers) | ||
@@ -102,3 +108,3 @@ .map(schemaTypeName => { | ||
.asKind('type') | ||
.withName(this.convertName('IDirectiveResolvers'), `<Context = ${this.config.contextType}>`) | ||
.withName(this.convertName('IDirectiveResolvers'), `<Context = ${this.config.contextType.type}>`) | ||
.withBlock(Object.keys(this._collectedDirectiveResolvers) | ||
@@ -161,3 +167,3 @@ .map(schemaTypeName => { | ||
.asKind('interface') | ||
.withName(name, `<Context = ${this.config.contextType}, ParentType = ${type}>`) | ||
.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${type}>`) | ||
.withBlock(node.fields.map((f) => f(node.name)).join('\n')); | ||
@@ -180,3 +186,3 @@ this._collectedResolvers[node.name] = name + '<Context>'; | ||
.asKind('interface') | ||
.withName(name, `<Context = ${this.config.contextType}, ParentType = ${node.name}>`) | ||
.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${node.name}>`) | ||
.withBlock(utils_1.indent(`__resolveType: TypeResolveFn<${possibleTypes}>`)).string; | ||
@@ -207,3 +213,3 @@ } | ||
.asKind('type') | ||
.withName(directiveName, `<Result, Parent, Context = ${this.config.contextType}, Args = { ${directiveArgs} }>`) | ||
.withName(directiveName, `<Result, Parent, Context = ${this.config.contextType.type}, Args = { ${directiveArgs} }>`) | ||
.withContent(`DirectiveResolverFn<Result, Parent, Context, Args>`).string; | ||
@@ -229,3 +235,3 @@ } | ||
.asKind('interface') | ||
.withName(name, `<Context = ${this.config.contextType}, ParentType = ${node.name}>`) | ||
.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${node.name}>`) | ||
.withBlock(utils_1.indent(`__resolveType: TypeResolveFn<${implementingTypes.map(name => `'${name}'`).join(' | ')}>`)) | ||
@@ -232,0 +238,0 @@ .string; |
@@ -54,3 +54,3 @@ "use strict"; | ||
const typeName = baseType.name; | ||
if (this._scalars[typeName] || graphql_1.isEnumType(baseType)) { | ||
if (this._scalars[typeName] || graphql_1.isEnumType(baseType) || graphql_1.isScalarType(baseType)) { | ||
if (field.alias && field.alias.value) { | ||
@@ -57,0 +57,0 @@ this._primitiveAliasedFields.push({ |
@@ -17,3 +17,3 @@ import { ScalarsMap, NamingConvention, ConvertFn, ConvertOptions } from './types'; | ||
typesPrefix: string; | ||
contextType: string; | ||
contextType: ParsedMapper; | ||
mappers: { | ||
@@ -20,0 +20,0 @@ [typeName: string]: ParsedMapper; |
@@ -13,3 +13,3 @@ import * as autoBind from 'auto-bind'; | ||
this._collectedDirectiveResolvers = {}; | ||
this._parsedConfig = Object.assign({ scalars: Object.assign({}, (defaultScalars || DEFAULT_SCALARS), (rawConfig.scalars || {})), convert: convertFactory(rawConfig), typesPrefix: rawConfig.typesPrefix || '', contextType: rawConfig.contextType || 'any', mappers: this.transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})); | ||
this._parsedConfig = Object.assign({ scalars: Object.assign({}, (defaultScalars || DEFAULT_SCALARS), (rawConfig.scalars || {})), convert: convertFactory(rawConfig), typesPrefix: rawConfig.typesPrefix || '', contextType: this.parseMapper(rawConfig.contextType || 'any'), mappers: this.transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})); | ||
autoBind(this); | ||
@@ -64,2 +64,8 @@ this._variablesTransfomer = new OperationVariablesToObject(this.scalars, this.convertName); | ||
}); | ||
if (this.config.contextType.isExternal) { | ||
if (!groupedMappers[this.config.contextType.source]) { | ||
groupedMappers[this.config.contextType.source] = []; | ||
} | ||
groupedMappers[this.config.contextType.source].push(this.config.contextType.type); | ||
} | ||
return Object.keys(groupedMappers).map(source => this.buildMapperImport(source, groupedMappers[source])); | ||
@@ -84,3 +90,3 @@ } | ||
.asKind('type') | ||
.withName(this.convertName('IResolvers'), `<Context = ${this.config.contextType}>`) | ||
.withName(this.convertName('IResolvers'), `<Context = ${this.config.contextType.type}>`) | ||
.withBlock(Object.keys(this._collectedResolvers) | ||
@@ -100,3 +106,3 @@ .map(schemaTypeName => { | ||
.asKind('type') | ||
.withName(this.convertName('IDirectiveResolvers'), `<Context = ${this.config.contextType}>`) | ||
.withName(this.convertName('IDirectiveResolvers'), `<Context = ${this.config.contextType.type}>`) | ||
.withBlock(Object.keys(this._collectedDirectiveResolvers) | ||
@@ -159,3 +165,3 @@ .map(schemaTypeName => { | ||
.asKind('interface') | ||
.withName(name, `<Context = ${this.config.contextType}, ParentType = ${type}>`) | ||
.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${type}>`) | ||
.withBlock(node.fields.map((f) => f(node.name)).join('\n')); | ||
@@ -178,3 +184,3 @@ this._collectedResolvers[node.name] = name + '<Context>'; | ||
.asKind('interface') | ||
.withName(name, `<Context = ${this.config.contextType}, ParentType = ${node.name}>`) | ||
.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${node.name}>`) | ||
.withBlock(indent(`__resolveType: TypeResolveFn<${possibleTypes}>`)).string; | ||
@@ -205,3 +211,3 @@ } | ||
.asKind('type') | ||
.withName(directiveName, `<Result, Parent, Context = ${this.config.contextType}, Args = { ${directiveArgs} }>`) | ||
.withName(directiveName, `<Result, Parent, Context = ${this.config.contextType.type}, Args = { ${directiveArgs} }>`) | ||
.withContent(`DirectiveResolverFn<Result, Parent, Context, Args>`).string; | ||
@@ -227,3 +233,3 @@ } | ||
.asKind('interface') | ||
.withName(name, `<Context = ${this.config.contextType}, ParentType = ${node.name}>`) | ||
.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${node.name}>`) | ||
.withBlock(indent(`__resolveType: TypeResolveFn<${implementingTypes.map(name => `'${name}'`).join(' | ')}>`)) | ||
@@ -230,0 +236,0 @@ .string; |
@@ -1,2 +0,2 @@ | ||
import { Kind, isObjectType, isUnionType, isInterfaceType, isEnumType, isEqualType, SchemaMetaFieldDef, TypeMetaFieldDef } from 'graphql'; | ||
import { Kind, isObjectType, isUnionType, isInterfaceType, isEnumType, isEqualType, SchemaMetaFieldDef, TypeMetaFieldDef, isScalarType } from 'graphql'; | ||
import { getBaseType, quoteIfNeeded } from './utils'; | ||
@@ -52,3 +52,3 @@ function isMetadataFieldName(name) { | ||
const typeName = baseType.name; | ||
if (this._scalars[typeName] || isEnumType(baseType)) { | ||
if (this._scalars[typeName] || isEnumType(baseType) || isScalarType(baseType)) { | ||
if (field.alias && field.alias.value) { | ||
@@ -55,0 +55,0 @@ this._primitiveAliasedFields.push({ |
{ | ||
"name": "graphql-codegen-visitor-plugin-common", | ||
"version": "0.19.0-alpha.d20bb04b", | ||
"version": "0.19.0-alpha.d32dbce6", | ||
"license": "MIT", | ||
@@ -11,3 +11,3 @@ "scripts": { | ||
"dependency-graph": "0.8.0", | ||
"graphql-codegen-plugin-helpers": "0.19.0-alpha.d20bb04b", | ||
"graphql-codegen-plugin-helpers": "0.19.0-alpha.d32dbce6", | ||
"graphql-tag": "2.10.1", | ||
@@ -22,3 +22,3 @@ "tslib": "1.9.3" | ||
"graphql": "14.1.1", | ||
"graphql-codegen-testing": "0.19.0-alpha.d20bb04b", | ||
"graphql-codegen-testing": "0.19.0-alpha.d32dbce6", | ||
"typescript": "3.3.3333" | ||
@@ -25,0 +25,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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
199203
2833
0
+ Addedgraphql-codegen-plugin-helpers@0.19.0-alpha.d32dbce6(transitive)
- Removedgraphql-codegen-plugin-helpers@0.19.0-alpha.d20bb04b(transitive)