How to use the nexus.objectType function in nexus

To help you get started, we’ve selected a few nexus examples, based on popular ways it is used in public projects.

github este / este / packages / api / schema / user.ts View on Github external
// requiredViewer throws, so the app can redirect.
export const requiredViewer = queryField('requiredViewer', {
  type: User,
  resolve: (_root, _args, context) => context.models.user.requiredViewer(),
});

export const SignInInput = inputObjectType({
  name: 'SignInInput',
  definition(t) {
    t.string('email');
    t.string('password');
    t.boolean('createAccount');
  },
});

export const SignInErrors = objectType({
  nonNullDefaults: { output: false },
  name: 'SignInErrors',
  definition(t) {
    t.field('email', { type: 'EmailError' });
    t.field('password', { type: 'PasswordError' });
  },
});

export const SignInPayload = objectType({
  nonNullDefaults: { output: false },
  name: 'SignInPayload',
  definition(t) {
    t.field('errors', { type: SignInErrors });
    t.string('token');
  },
});
github jferrettiboke / stripe-graphql / src / graphql / country-specs / AccountVerificationFields.ts View on Github external
import { objectType } from "nexus";

export const AccountVerificationFields = objectType({
  name: "AccountVerificationFields",
  definition(t) {
    t.field("individual", { type: "VerificationFields" });
    t.field("company", { type: "VerificationFields" });
  }
});
github Novvum / MarvelQL / packages / graphql / schema / types / Event.ts View on Github external
import { objectType, inputObjectType, enumType } from 'nexus';
export const Event = objectType({
    name: "Event",
    definition(t) {
        t.implements("MarvelNode");
        t.string("title", {
            nullable: true,
            description: 'The title of the event.'
        });
        t.string("description", {
            nullable: true,
            description: 'A description of the event.',
        });
        t.list.field("urls", {
            type: "MarvelUrl",
            nullable: true,
            description: 'A set of public web site URLs for the resource.',
        });
github arkhn / pyrog / server-v2 / src / types / Resource.ts View on Github external
import { objectType, FieldResolver } from 'nexus'
import { AttributeCreateWithoutResourceInput } from '@prisma/photon'
import { fetchResourceSchema } from 'utils'

export const Resource = objectType({
  name: 'Resource',
  definition(t) {
    t.model.id()

    t.model.label()
    t.model.profile()
    t.model.fhirType()

    t.model.primaryKeyOwner()
    t.model.primaryKeyTable()
    t.model.primaryKeyColumn()

    t.model.attributes()
    t.model.source()

    t.model.updatedAt()
github jferrettiboke / stripe-graphql / src / graphql / balance / BalanceItem.ts View on Github external
import { objectType } from "nexus";

export const BalanceItem = objectType({
  name: "BalanceItem",
  definition(t) {
    t.string("currency");
    t.int("amount");
    t.field("source_types", {
      type: "BalanceSourceTypes",
      description: "Breakdown of balance by source types."
    });
  }
});
github jferrettiboke / stripe-graphql / src / graphql / customers / Customer.ts View on Github external
import { objectType } from "nexus";

export const Customer = objectType({
  name: "Customer",
  definition(t) {
    t.implements("Node", "Metadata");
    t.field("address", {
      type: "Address",
      nullable: true,
      description: "The customer’s address."
    });
    t.list.field("balance", {
      type: "CustomerBalanceTransaction",
      description:
        "Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.",
      async resolve(customer, args, context, info) {
        const { data } = await context.stripe.customers.listBalanceTransactions(
          customer.id
        );
github prisma / prisma-examples / misc / react-graphql-fullstack / server / src / schema.ts View on Github external
filtering: true,
      pagination: false,
    })

    t.list.field('feed', {
      type: 'Post',
      resolve: (_parent, _args, ctx) => {
        return ctx.photon.posts.findMany({
          where: { published: true },
        })
      },
    })
  },
})

const Mutation = objectType({
  name: 'Mutation',
  definition(t) {
    t.crud.createOneUser({
      alias: 'signupUser',
    })
    t.crud.deleteOnePost({ alias: 'deletePost' })

    t.field('createDraft', {
      type: 'Post',
      args: {
        title: stringArg({ nullable: false }),
        content: stringArg(),
        authorEmail: stringArg(),
      },
      resolve: (_, { title, content, authorEmail }, ctx) => {
        return ctx.photon.posts.create({