Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
resolve: (_parent, _args, ctx) => {
return ctx.photon.users.findMany();
}
});
t.list.field('feedDecks', {
type: 'Deck',
resolve: (_parent, _args, ctx) => {
return ctx.photon.decks.findMany();
}
});
t.list.field('deckConnection', {
type: 'Deck',
args: {
first: intArg(),
last: stringArg()
},
resolve: (_parent, args, ctx) => {
const { first, last } = args;
return ctx.photon.decks.findMany({
first: first,
after: last
});
}
});
// t.list.field('feed', {
// type: 'Post',
// resolve: (_parent, _args, ctx) => {
// return ctx.photon.posts.findMany({
// where: { published: true },
definition(t) {
t.crud.blogs({
pagination: false,
})
t.crud.users({ filtering: true, alias: 'people' })
t.crud.posts({ type: 'CustomPost', ordering: true, filtering: true })
//
// Examples showing custom resolvers
//
t.field('blog', {
type: 'Blog',
args: {
id: intArg({ required: true }),
},
resolve(_root, args, ctx) {
return ctx.photon.blogs
.findOne({
where: {
id: args.id,
},
})
.then(result => {
if (result === null) {
throw new Error(`No blog with id of "${args.id}"`)
}
return result
})
},
})
definition(t) {
t.list.field("customers", {
type: "Customer",
args: {
endingBefore: stringArg(),
startingAfter: stringArg(),
limit: intArg()
},
async resolve(
root,
{ endingBefore, startingAfter, limit },
context,
info
) {
let options = {};
if (startingAfter) {
options = { ...options, starting_after: startingAfter };
}
if (endingBefore) {
options = { ...options, ending_before: endingBefore };
}
if (limit) {
options = { ...options, limit };
definition(t) {
t.list.field('articles', {
nullable: true,
type: Article,
args: {
limit: intArg({ default: 3, required: true })
},
resolve: (_, args) => {
const { limit } = args;
return articles.slice(0, limit);
},
});
t.list.field('authors', {
nullable: true,
type: Author,
resolve: () => authors,
});
},
});
description: 'Fetches a single character by id.',
args: {
where: arg({ type: "CharacterWhereInput" }),
},
async resolve(_, args, ctx, info) {
return await ctx.charactersModel.getOne(args.where);
},
});
t.list.field("comics", {
type: "Comic",
nullable: true,
description: 'Fetches a list of comics.',
args: {
where: arg({ type: "ComicWhereInput" }),
orderBy: arg({ type: "ComicOrderBy" }),
offset: intArg({ description: "Skips the specified number of resources in the result set." }),
limit: intArg({ description: "Limit the result set to the specified number of resources." }),
},
async resolve(_, args, ctx, info) {
return await ctx.comicsModel.getMany({
where: args.where,
orderBy: args.orderBy,
limit: args.limit,
offset: args.offset
});
},
});
t.field("getComic", {
type: "Comic",
nullable: true,
description: 'Fetches a single comic by id.',
args: {