@raynode/graphql-connector
Advanced tools
Comparing version
@@ -66,3 +66,3 @@ "use strict"; | ||
type: model.fields.reduce(function (dataFields, field) { | ||
var type = typeMapper(field); | ||
var type = typeMapper(field, model); | ||
dataFields[field.name] = { type: field.nonNull ? new graphql_1.GraphQLNonNull(type) : type }; | ||
@@ -69,0 +69,0 @@ return dataFields; |
import { AnyModel, PartialAssociation, PartialAttribute } from './model'; | ||
export declare type ModelMapperFn<Types, Models> = <Key extends keyof Models>(model: Models[Key], addAttribute: (attribute: PartialAttribute<Types>) => void, addAssociation: (association: PartialAssociation<keyof Models>) => void) => void; | ||
export declare type ModelMapperFn<Types, Models> = <Key extends keyof Models>(model: Models[Key], addAttribute: (attribute: PartialAttribute<Types>) => void, addAssociation: (association: PartialAssociation<Models>) => void) => void; | ||
export declare type GeneratedModelMapper<Types, Models> = <Key extends keyof Models>(key: Key, model: Models[Key]) => AnyModel<Types, Models, Models[Key]>; | ||
export declare type ModelMapper<Types, Models> = (mapper: ModelMapperFn<Types, Models>) => GeneratedModelMapper<Types, Models>; | ||
export declare const createModelMapper: <Types, Models>(mapper: ModelMapperFn<Types, Models>) => GeneratedModelMapper<Types, Models>; |
@@ -9,3 +9,3 @@ "use strict"; | ||
var associations = {}; | ||
mapper(model, function (attribute) { return (attributes[attribute.name] = attribute); }, function (association) { return (associations[association.name] = association); }); | ||
mapper(model, function (attribute) { return attributes[attribute.name] = attribute; }, function (association) { return associations[association.name] = association; }); | ||
return creator(key, attributes, associations, model); | ||
@@ -12,0 +12,0 @@ }; |
import { GraphQLType } from 'graphql'; | ||
import { Attribute, BaseField, ExtendedModel } from './model'; | ||
export declare type TypeMapper<Types, Models> = (type: Attribute<Types>) => GraphQLType; | ||
export declare const applyTypeMapper: <Types, Models>(typeMapper: TypeMapper<Types, Models>, getModel: (name: keyof Models) => ExtendedModel<Types, Models>) => (field: BaseField<Types, Models>) => GraphQLType; | ||
import { AnyModel, Attribute, BaseField, ExtendedModel } from './model'; | ||
export declare type TypeMapper<Types, Models> = (type: Attribute<Types>, model: AnyModel<Types, Models>) => GraphQLType; | ||
export declare const applyTypeMapper: <Types, Models>(typeMapper: TypeMapper<Types, Models>, getModel: (name: keyof Models) => ExtendedModel<Types, Models>) => (field: BaseField<Types, Models>, model: import("./model").Model<any, any, Types, Models, any>) => GraphQLType; |
@@ -5,10 +5,10 @@ "use strict"; | ||
var model_1 = require("./model"); | ||
exports.applyTypeMapper = function (typeMapper, getModel) { return function (field) { | ||
exports.applyTypeMapper = function (typeMapper, getModel) { return function (field, model) { | ||
if (model_1.isAssociationField(field)) { | ||
var model = getModel(field.model); | ||
return field.list ? model.types.list : model.types.type; | ||
var model_2 = getModel(field.model); | ||
return field.list ? model_2.types.list : model_2.types.type; | ||
} | ||
var type = typeMapper(field); | ||
var type = typeMapper(field, model); | ||
return field.list ? new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(type)) : type; | ||
}; }; | ||
//# sourceMappingURL=type-converter.js.map |
{ | ||
"name": "@raynode/graphql-connector", | ||
"version": "0.2.1", | ||
"version": "0.2.4", | ||
"description": "", | ||
@@ -64,3 +64,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "bae77e6301119cc09d8bc5ca20dbc931bc6c7d75" | ||
"gitHead": "48b89222c9408b87c1625544cbe719525319cbdf" | ||
} |
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
34533
0.38%