Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
});
}
});
function nexusExtendType(
typeConfig: PrismaExtendTypeConfig,
builder: PrismaSchemaBuilder,
): core.NexusExtendTypeDef {
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)
},
})
}
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;
}
});
}
});
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;
}
});
}
});
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;
}
});
}
});
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;
}
});
}
});
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 })
},
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;
}
});
}
});