How to use the gqliteral.idArg function in gqliteral

To help you get started, we’ve selected a few gqliteral 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 prisma-labs / nexus-prisma / example / ecommerce / src / resolvers / roots / Mutation.ts View on Github external
productIds: idArg({ required: true, list: true }),
      collectionId: idArg({ required: true }),
    },
    resolve: async (_, args, ctx) => {
      const collection = await ctx.prisma.updateCollection({
        where: { id: args.collectionId },
        data: { products: { connect: args.productIds.map(id => ({ id })) } },
      })

      return collection
    },
  })

  t.field('removeProductsFromCollection', 'Collection', {
    args: {
      productIds: idArg({ required: true, list: true }),
      collectionId: idArg({ required: true }),
    },
    resolve: async (_, args, ctx) => {
      const collection = await ctx.prisma.updateCollection({
        where: { id: args.collectionId },
        data: { products: { disconnect: args.productIds.map(id => ({ id })) } },
      })

      return collection
    },
  })

  t.field('createProduct', 'Product', {
    args: {
      data: arg('CreateProductInput', { required: true }),
    },
github prisma-labs / nexus-prisma / example / ecommerce / src / resolvers / roots / Mutation.ts View on Github external
export const Mutation = prismaObjectType('Mutation', t => {
  t.field('addProductsToCollection', 'Collection', {
    args: {
      productIds: idArg({ required: true, list: true }),
      collectionId: idArg({ required: true }),
    },
    resolve: async (_, args, ctx) => {
      const collection = await ctx.prisma.updateCollection({
        where: { id: args.collectionId },
        data: { products: { connect: args.productIds.map(id => ({ id })) } },
      })

      return collection
    },
  })

  t.field('removeProductsFromCollection', 'Collection', {
    args: {
      productIds: idArg({ required: true, list: true }),
      collectionId: idArg({ required: true }),
    },
github prisma-labs / nexus-prisma / example / ecommerce / src / resolvers / roots / Query.ts View on Github external
export const Query = prismaObjectType('Query', t => {
  t.prismaFields({ pick: ['products', 'options', 'brands'] })

  t.field('collection', 'Collection', {
    args: {
      collectionId: idArg({ required: true }),
    },
    resolve: (root, args, ctx) => {
      return ctx.prisma.collection({ id: args.collectionId })
    },
  })
})

gqliteral

Scalable, strongly typed GraphQL schema development

MIT
Latest version published 5 years ago

Package Health Score

56 / 100
Full package analysis

Similar packages