How to use gqliteral - 10 common examples

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 / plugin / prisma.ts View on Github external
fieldArg.type.name as any,
        typeToFieldOpts(fieldArg.type),
      )

      return acc
    },
    {},
  )

  return {
    args: gqliteralArgs,
    typesToExport,
  }
}

const PageInfo = objectType('PageInfo', t => {
  t.boolean('hasSomething')
})

// function relayConnection(field: string) {
//   const Edge = objectType(`${field}Edge`, t => {
//     t.id('id')
//     t.field('node', field)
//   })
//   const Connection = objectType(`${field}Connection`, t => {
//     t.field('edges', `${field}Edge`)
//   })

//   return [PageInfo, Edge, Connection]
// }

function exportRelayConnectionTypes(
github prisma-labs / nexus-prisma / src / gqliteral / schema.ts View on Github external
prisma: path.join(__dirname, '../generated/prisma-client/index.ts'),
      ctx: path.join(__dirname, '../context.ts'),
    },

    contextType: 'ctx.Context',

    rootTypes: {
      User: 'prisma.User',
      //Post: 'prisma.Post',
    },
  },

  // plugins: [prismaPlugin],
})

export const schema = buildSchema({
  types: allTypes,

  outputs: {
    schema: path.join(__dirname, '../../schema.graphql'),
    typegen: path.join(__dirname, '../generated/gqliteral.ts'),
  },

  typegen: {
    imports: {
      prisma: path.join(__dirname, '../generated/prisma-client/index.ts'),
      ctx: path.join(__dirname, '../context.ts'),
    },

    contextType: 'ctx.Context',

    rootTypes: {
github prisma-labs / nexus-prisma / plugin / index.ts View on Github external
export function buildPrismaSchema(options: PrismaSchemaConfig) {
  const { schema, metadata } = makeSchemaWithMetadata(
    options,
    PrismaSchemaBuilder,
  )

  // Only in development envs do we want to worry about regenerating the
  // schema definition and/or generated types.
  const {
    shouldGenerateArtifacts = process.env.NODE_ENV !== "production",
  } = options;

  if (shouldGenerateArtifacts) {
    // Generating in the next tick allows us to use the schema
    // in the optional thunk for the typegen config
    metadata.generateArtifacts(schema);
  }
github prisma-labs / nexus-prisma / plugin / prisma.ts View on Github external
},
  fn?: (t: PrismaObjectType) => void,
): WrappedType[] {
  // TODO refactor + make use of `objectTypeName`
  const realTypeName =
    typeof typeName === 'string' ? typeName : typeName.prismaTypeName
  const objectType = new PrismaObjectType(realTypeName)

  if (fn === undefined) {
    return [new WrappedType(objectType), ...objectType.prismaFields()]
  }

  // mutate objectType
  fn(objectType)

  return [new WrappedType(objectType), ...objectType.getTypesToExport()]
}
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 6 years ago

Package Health Score

56 / 100
Full package analysis

Similar packages