Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.')
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)
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) {
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)
})
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.')
}
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
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');