How to use the graphql-compose-mongoose.default 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 zapkub / cu-vivid-museum-wiki / legacy / server / schema.js View on Github external
const { Plant, Garden, Herbarium, Museum, Report } = context

  const defaultTypeArgs = {
    resolvers: {
      findMany: {
        sort: true,
        skip: true,
        limit: {
          defaultValue: 100
        }
      }
    }
  }

  const ReportTC = composeWithMongoose(Report)
  const PlantTC = composeWithMongoose(Plant, defaultTypeArgs)
  const HerbariumTC = composeWithMongoose(Herbarium, defaultTypeArgs)
  const GardenTC = composeWithMongoose(Garden, defaultTypeArgs)
  const MuseumTC = composeWithMongoose(Museum, defaultTypeArgs)

  const modelsTC = { PlantTC, GardenTC, MuseumTC, HerbariumTC }
  modelsTC.PlantSearchResultItemType = require('./types/PlantSearchResultItem.type')(modelsTC)

  // setup resolver
  require('./resolvers')(modelsTC)

  const checkPermission = (resolvers) => {
    Object.keys(resolvers).forEach((k) => {
    resolvers[k] = resolvers[k].wrapResolve(next => (rp) => { // eslint-disable-line
      // rp = resolveParams = { source, args, context, info }
      if (!rp.context.isAuth) {
        throw new Error('You should be admin, to have access to this action.')
github zapkub / cu-vivid-museum-wiki / legacy / server / schema.js View on Github external
const defaultTypeArgs = {
    resolvers: {
      findMany: {
        sort: true,
        skip: true,
        limit: {
          defaultValue: 100
        }
      }
    }
  }

  const ReportTC = composeWithMongoose(Report)
  const PlantTC = composeWithMongoose(Plant, defaultTypeArgs)
  const HerbariumTC = composeWithMongoose(Herbarium, defaultTypeArgs)
  const GardenTC = composeWithMongoose(Garden, defaultTypeArgs)
  const MuseumTC = composeWithMongoose(Museum, defaultTypeArgs)

  const modelsTC = { PlantTC, GardenTC, MuseumTC, HerbariumTC }
  modelsTC.PlantSearchResultItemType = require('./types/PlantSearchResultItem.type')(modelsTC)

  // setup resolver
  require('./resolvers')(modelsTC)

  const checkPermission = (resolvers) => {
    Object.keys(resolvers).forEach((k) => {
    resolvers[k] = resolvers[k].wrapResolve(next => (rp) => { // eslint-disable-line
      // rp = resolveParams = { source, args, context, info }
      if (!rp.context.isAuth) {
        throw new Error('You should be admin, to have access to this action.')
      }
      return next(rp)
github zapkub / cu-vivid-museum-wiki / legacy / server / schema.js View on Github external
module.exports = (context) => {
  const { Plant, Garden, Herbarium, Museum, Report } = context

  const defaultTypeArgs = {
    resolvers: {
      findMany: {
        sort: true,
        skip: true,
        limit: {
          defaultValue: 100
        }
      }
    }
  }

  const ReportTC = composeWithMongoose(Report)
  const PlantTC = composeWithMongoose(Plant, defaultTypeArgs)
  const HerbariumTC = composeWithMongoose(Herbarium, defaultTypeArgs)
  const GardenTC = composeWithMongoose(Garden, defaultTypeArgs)
  const MuseumTC = composeWithMongoose(Museum, defaultTypeArgs)

  const modelsTC = { PlantTC, GardenTC, MuseumTC, HerbariumTC }
  modelsTC.PlantSearchResultItemType = require('./types/PlantSearchResultItem.type')(modelsTC)

  // setup resolver
  require('./resolvers')(modelsTC)

  const checkPermission = (resolvers) => {
    Object.keys(resolvers).forEach((k) => {
    resolvers[k] = resolvers[k].wrapResolve(next => (rp) => { // eslint-disable-line
      // rp = resolveParams = { source, args, context, info }
      if (!rp.context.isAuth) {
github zapkub / cu-vivid-museum-wiki / legacy / server / schema.js View on Github external
resolvers: {
      findMany: {
        sort: true,
        skip: true,
        limit: {
          defaultValue: 100
        }
      }
    }
  }

  const ReportTC = composeWithMongoose(Report)
  const PlantTC = composeWithMongoose(Plant, defaultTypeArgs)
  const HerbariumTC = composeWithMongoose(Herbarium, defaultTypeArgs)
  const GardenTC = composeWithMongoose(Garden, defaultTypeArgs)
  const MuseumTC = composeWithMongoose(Museum, defaultTypeArgs)

  const modelsTC = { PlantTC, GardenTC, MuseumTC, HerbariumTC }
  modelsTC.PlantSearchResultItemType = require('./types/PlantSearchResultItem.type')(modelsTC)

  // setup resolver
  require('./resolvers')(modelsTC)

  const checkPermission = (resolvers) => {
    Object.keys(resolvers).forEach((k) => {
    resolvers[k] = resolvers[k].wrapResolve(next => (rp) => { // eslint-disable-line
      // rp = resolveParams = { source, args, context, info }
      if (!rp.context.isAuth) {
        throw new Error('You should be admin, to have access to this action.')
      }
      return next(rp)
    })
github zapkub / cu-vivid-museum-wiki / legacy / server / schema.js View on Github external
const defaultTypeArgs = {
    resolvers: {
      findMany: {
        sort: true,
        skip: true,
        limit: {
          defaultValue: 100
        }
      }
    }
  }

  const ReportTC = composeWithMongoose(Report)
  const PlantTC = composeWithMongoose(Plant, defaultTypeArgs)
  const HerbariumTC = composeWithMongoose(Herbarium, defaultTypeArgs)
  const GardenTC = composeWithMongoose(Garden, defaultTypeArgs)
  const MuseumTC = composeWithMongoose(Museum, defaultTypeArgs)

  const modelsTC = { PlantTC, GardenTC, MuseumTC, HerbariumTC }
  modelsTC.PlantSearchResultItemType = require('./types/PlantSearchResultItem.type')(modelsTC)

  // setup resolver
  require('./resolvers')(modelsTC)

  const checkPermission = (resolvers) => {
    Object.keys(resolvers).forEach((k) => {
    resolvers[k] = resolvers[k].wrapResolve(next => (rp) => { // eslint-disable-line
      // rp = resolveParams = { source, args, context, info }
      if (!rp.context.isAuth) {
        throw new Error('You should be admin, to have access to this action.')
      }
github zapkub / cu-vivid-museum-wiki / legacy / server / models / Location.js View on Github external
const keystone = require('keystone')
const composeWithMongoose = require('graphql-compose-mongoose').default

const Location = new keystone.List('Location', {
})

Location.add({
  name: { type: String, required: true },
  label: { type: String },
  description: { type: String, required: false }
})

Location.relationship({ ref: 'Plant', path: 'displayLocation' })
Location.register()

const LocationTC = composeWithMongoose(Location.model, {})

exports.LocationTC = LocationTC
github zapkub / cu-vivid-museum-wiki / server / models / Category.js View on Github external
const Types = keystone.Field.Types;
const PlantCategory = new keystone.List('Category', {
  autokey: { from: 'name', path: 'key', unique: true },
});

PlantCategory.add({
  name: { type: String, required: true, unique: true },
  thumbnailImage: { type: Types.CloudinaryImage },
  heroImage: { type: Types.CloudinaryImage },
});

PlantCategory.relationship({ ref: 'Plant', path: 'category' });
PlantCategory.register();

const CategoryTC = composeWithMongoose(PlantCategory.model, {

});
CategoryTC.addFields({
  heroImageURL: {
    type: 'String',
    resolve: (source) => {
      if (!source.heroImage) {
        return null;
      }
      return source.heroImage.url;
    },
  },
});
CategoryTC.get('$findMany').removeArg('filter');
CategoryTC.get('$findMany').removeArg('limit');
CategoryTC.get('$findMany').removeArg('skip');