How to use the graphql-compose-mongoose.composeTypeFromMongoose function in graphql-compose-mongoose

To help you get started, we’ve selected a few graphql-compose-mongoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-compose / graphql-compose / src / metaApiProposal.js View on Github external
dob: String,
  createdAt: Date,
  updatedAt: Date,
});

import { composeType, composeField, composeResolve, composeInterface, composeStorage } from 'graphql-compose';
import { description, only, remove, restrict, add } from 'graphql-compose/type';
import { composeTypeFromMongoose } from 'graphql-compose-mongoose';
import { GraphQLString } from 'graphql';



//---------- TYPE MODIFICATORS

composeType('User',
  composeTypeFromMongoose(UserMongooseModel),
     addResolverParam('model', UserMongooseModel), // internally added by `composeTypeFromMongoose`
  composeInterface('Timestable'), // internally call composeStorage.Interfaces.get('Timestable')
  description('User model description'),
  only(['myName', 'surname']), // get only described fields
  remove(['stats', 'password']), // ... or leave others, and remove just listed here
  rename({
    myName: 'name',
    surname: 'lastname',
  }),
  restrict({
    hasAccess: (source, args, context, info) => {
      return context.isAdmin;
    },
    fields: ['name', 'dob'],
  }),
  restrict({