sarkistlt / mongoose-schema-to-graphql

Use Mongoose schema to generate graphQL type.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mapping fields name

neoPix opened this issue · comments

Hi,

Is there a way to map the fields (eg. _id => id) and vice versa ?

Something like this :

createType({
    name: 'User',
    description: 'an application user',
    class: 'GraphQLObjectType',
    schema: User,
    map: {
        displayName: 'name',
        '_id': 'id'
    },// or Map, or func
    exclude: ['auths']
})

Thanks.

Hi, sorry for late response. it is a good idea, right now you can use workaround for example:

createType({
    name: 'User',
    description: 'an application user',
    class: 'GraphQLObjectType',
    schema: User,
    exclude: ['_id'],
    extend: {
      id: {type: GraphQLInt},
   },
})

but you can anytime submit PR or I can add that function but can't give any timelines, pretty busy right now.