How to use the nexus.extendType 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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jferrettiboke / stripe-graphql / src / graphql / products / extends / PlanProduct.ts View on Github external
import { extendType } from "nexus";

export const planProductField = extendType({
  type: "Plan",
  definition(t) {
    t.field("product", {
      type: "Product",
      description: "The product whose pricing this plan determines.",
      async resolve(plan, args, context) {
        // @ts-ignore
        return await context.stripe.products.retrieve(plan.product);
      }
    });
  }
});
github prisma-labs / nexus-prisma / packages / nexus-prisma / src / definitions / extendType.ts View on Github external
function nexusExtendType<TypeName extends string>(
  typeConfig: PrismaExtendTypeConfig<TypeName>,
  builder: PrismaSchemaBuilder,
): core.NexusExtendTypeDef<TypeName> {
  let { definition, ...rest } = typeConfig
  const datamodelInfo = builder.getDatamodelInfo()
  const prismaType = prismaTypeExtend(
    datamodelInfo,
    typeConfig,
    builder.getConfig(),
  )
  const prismaSchema = datamodelInfo.schema

  return extendType({
    ...rest,
    definition(block) {
      const prismaBlock = prismaExtendTypeBlock(
        typeConfig.type,
        block,
        prismaType,
        prismaSchema,
      )

      definition(prismaBlock)
    },
  })
}
github jferrettiboke / stripe-graphql / src / graphql / cards / extends / CustomerCards.ts View on Github external
import { extendType } from "nexus";

export const CustomerCards = extendType({
  type: "Customer",
  definition(t) {
    t.list.field("cards", {
      type: "Card",
      async resolve({ id }, args, context) {
        const { data } = await context.stripe.customers.listSources(id, {
          object: "card"
        });
        return data;
      }
    });
  }
});
github jferrettiboke / stripe-graphql / src / graphql / plans / extends / ProductPlans.ts View on Github external
import { extendType } from "nexus";

export const productPlansField = extendType({
  type: "Service",
  definition(t) {
    t.list.field("plans", {
      type: "Plan",
      async resolve(product, args, context, info) {
        const { data } = await context.stripe.plans.list({
          product: product.id
        });
        return data;
      }
    });
  }
});
github jferrettiboke / stripe-graphql / src / graphql / bank-accounts / extends / AccountBankAccounts.ts View on Github external
import { extendType } from "nexus";

export const AccountBankAccounts = extendType({
  type: "Account",
  definition(t) {
    t.list.field("bankAccounts", {
      type: "BankAccount",
      async resolve({ id }, args, context) {
        const { data } = await context.stripe.accounts.listExternalAccounts(
          id,
          {
            object: "bank_account"
          }
        );
        return data;
      }
    });
  }
});
github jferrettiboke / stripe-graphql / src / graphql / cards / extends / AccountCards.ts View on Github external
import { extendType } from "nexus";

export const AccountCards = extendType({
  type: "Account",
  definition(t) {
    t.list.field("cards", {
      type: "Card",
      async resolve({ id }, args, context) {
        const { data } = await context.stripe.accounts.listExternalAccounts(
          id,
          {
            object: "card"
          }
        );
        return data;
      }
    });
  }
});
github jferrettiboke / stripe-graphql / src / graphql / subscriptions / Query.ts View on Github external
import { extendType, idArg } from "nexus";

export const SubscriptionrQueries = extendType({
  type: "Query",
  definition(t) {
    t.list.field("subscriptions", {
      type: "StripeSubscription",
      async resolve(root, args, context, info) {
        const { data } = await context.stripe.subscriptions.list();
        return data;
      }
    });

    t.field("subscription", {
      type: "StripeSubscription",
      nullable: true,
      args: {
        id: idArg({ required: true })
      },
github jferrettiboke / stripe-graphql / src / graphql / bank-accounts / extends / CustomerBankAccounts.ts View on Github external
import { extendType } from "nexus";

export const CustomerBankAccounts = extendType({
  type: "Customer",
  definition(t) {
    t.list.field("bankAccounts", {
      type: "BankAccount",
      async resolve({ id }, args, context) {
        const { data } = await context.stripe.customers.listSources(id, {
          object: "bank_account"
        });
        return data;
      }
    });
  }
});