How to use the gqliteral.inputObjectType 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
})

export const CreateVariantInput = inputObjectType('CreateVariantInput', t => {
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
  t.int('price', { required: true })
})

export const CreateProductInput = inputObjectType('CreateProductInput', t => {
  t.string('name', { required: true })
  t.field('brand', 'UniqueInput', { required: true })
  t.field('attributesIds', 'UniqueInput', { required: true, list: true })
  t.field('variants', 'CreateVariantInput', { required: true, list: true })
})

export const UpdateVariantInput = inputObjectType('UpdateVariantInput', t => {
  t.id('id', { required: true })
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
  t.int('price', { required: true })
})

export const UpdateProductInput = inputObjectType('UpdateProductInput', t => {
  t.id('id', { required: true })
  t.string('name', { required: true })
  t.field('brand', 'UniqueInput', { required: true })
  t.field('attributesIds', 'UniqueInput', { required: true, list: true })
  t.field('variants', 'UpdateVariantInput', { required: true, list: true })
})

export const Mutation = prismaObjectType('Mutation', t => {
  t.field('addProductsToCollection', 'Collection', {
github prisma-labs / nexus-prisma / example / ecommerce / src / resolvers / roots / Mutation.ts View on Github external
import { arg, idArg, inputObjectType } from 'gqliteral'
import { prismaObjectType } from '../../../src'
import { VariantCreateInput } from '../../generated/prisma-client'

export const UniqueInput = inputObjectType('UniqueInput', t => {
  t.id('id', { required: true })
})

export const CreateVariantInput = inputObjectType('CreateVariantInput', t => {
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
  t.int('price', { required: true })
})

export const CreateProductInput = inputObjectType('CreateProductInput', t => {
  t.string('name', { required: true })
  t.field('brand', 'UniqueInput', { required: true })
  t.field('attributesIds', 'UniqueInput', { required: true, list: true })
  t.field('variants', 'CreateVariantInput', { required: true, list: true })
})
github prisma-labs / nexus-prisma / plugin / prisma.ts View on Github external
function exportInputObjectType(
  inputType: GraphQLTypeObject,
  typesMap: TypesMap,
  seen: Dictionary,
): WrappedType[] {
  seen[inputType.name] = true

  const typesToExport: WrappedType[] = []

  const inputObject = inputObjectType(inputType.name, arg => {
    inputType.fields.forEach(field => {
      if (field.type.isScalar) {
        return getObjectInputArg(arg, field, typeToFieldOpts(field.type))
      }

      if (!seen[field.type.name]) {
        typesToExport.push(
          ...exportInputObjectType(
            typesMap.types[field.type.name],
            typesMap,
            seen,
          ),
        )
      }

      arg.field(field.name, field.type.name as any, typeToFieldOpts(field.type))
github prisma-labs / nexus-prisma / example / ecommerce / src / resolvers / roots / Mutation.ts View on Github external
import { arg, idArg, inputObjectType } from 'gqliteral'
import { prismaObjectType } from '../../../src'
import { VariantCreateInput } from '../../generated/prisma-client'

export const UniqueInput = inputObjectType('UniqueInput', t => {
  t.id('id', { required: true })
})

export const CreateVariantInput = inputObjectType('CreateVariantInput', t => {
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
  t.int('price', { required: true })
})

export const CreateProductInput = inputObjectType('CreateProductInput', t => {
  t.string('name', { required: true })
  t.field('brand', 'UniqueInput', { required: true })
  t.field('attributesIds', 'UniqueInput', { required: true, list: true })
  t.field('variants', 'CreateVariantInput', { required: true, list: true })
})

export const UpdateVariantInput = inputObjectType('UpdateVariantInput', t => {
  t.id('id', { required: true })
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
github prisma-labs / nexus-prisma / example / ecommerce / src / resolvers / roots / Mutation.ts View on Github external
export const CreateProductInput = inputObjectType('CreateProductInput', t => {
  t.string('name', { required: true })
  t.field('brand', 'UniqueInput', { required: true })
  t.field('attributesIds', 'UniqueInput', { required: true, list: true })
  t.field('variants', 'CreateVariantInput', { required: true, list: true })
})

export const UpdateVariantInput = inputObjectType('UpdateVariantInput', t => {
  t.id('id', { required: true })
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
  t.int('price', { required: true })
})

export const UpdateProductInput = inputObjectType('UpdateProductInput', t => {
  t.id('id', { required: true })
  t.string('name', { required: true })
  t.field('brand', 'UniqueInput', { required: true })
  t.field('attributesIds', 'UniqueInput', { required: true, list: true })
  t.field('variants', 'UpdateVariantInput', { required: true, list: true })
})

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 },
github prisma-labs / nexus-prisma / example / ecommerce / src / resolvers / roots / Mutation.ts View on Github external
import { arg, idArg, inputObjectType } from 'gqliteral'
import { prismaObjectType } from '../../../src'
import { VariantCreateInput } from '../../generated/prisma-client'

export const UniqueInput = inputObjectType('UniqueInput', t => {
  t.id('id', { required: true })
})

export const CreateVariantInput = inputObjectType('CreateVariantInput', t => {
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
  t.int('price', { required: true })
})

export const CreateProductInput = inputObjectType('CreateProductInput', t => {
  t.string('name', { required: true })
  t.field('brand', 'UniqueInput', { required: true })
  t.field('attributesIds', 'UniqueInput', { required: true, list: true })
  t.field('variants', 'CreateVariantInput', { required: true, list: true })
})

export const UpdateVariantInput = inputObjectType('UpdateVariantInput', t => {
  t.id('id', { required: true })
  t.field('optionsValueIds', 'UniqueInput', { list: true, required: true })
  t.boolean('availableForSale', { required: true })
  t.int('price', { required: true })
})

export const UpdateProductInput = inputObjectType('UpdateProductInput', t => {
  t.id('id', { required: true })
  t.string('name', { required: true })

gqliteral

Scalable, strongly typed GraphQL schema development

MIT
Latest version published 5 years ago

Package Health Score

56 / 100
Full package analysis

Similar packages