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