Skip to content

Instantly share code, notes, and snippets.

@maticzav
Last active December 30, 2017 09:02
Show Gist options
  • Save maticzav/c5c5b47ba6d6e26f4773da112f72d4db to your computer and use it in GitHub Desktop.
Save maticzav/c5c5b47ba6d6e26f4773da112f72d4db to your computer and use it in GitHub Desktop.
// src/resolvers/Mutation/file.ts
export const file = {
renameFile: async (parent, {id, name}, ctx: Context, info) => {
return ctx.db.mutation.updateFile({ data: { name }, where: { id } }, info)
},
deleteFile: async (parent, { id }, ctx: Context, info) => {
return await ctx.db.mutation.deleteFile({ where: { id } }, info)
}
}
// src/resolvers/index.ts
import { file } from './Mutation/file'
export const resolvers = {
Query: {
file: async (parent, {id}, context, info) => {
return context.db.query.file({ where: { id } }, info)
},
files: async (parent, args, context, info) => {
return context.db.query.files(args, info)
},
},
Mutation: {
...file,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment