redwoodjs-stripe
redwoodjs-stripe copied to clipboard
Better way to export services
At the moment the exporting of services to use in rw app feels a bit hacky.
inside plugin
redwoodjs-stripe/src/api/services/index.js
import { checkout, createStripeCheckoutSession } from './checkouts/checkouts'
import * as stripeItems from './stripeItems/stripeItems'
import { stripeCustomerSearch, retrieveStripeCustomer, createStripeCustomer, searchLatestStripeCustomer} from './customers/customers'
import * as customerPortal from './customerPortal/customerPortal'
// shape services object
export const stripeServices = {
checkouts_checkouts: { checkout, createStripeCheckoutSession },
customers_customers: {
stripeCustomerSearch, retrieveStripeCustomer, createStripeCustomer, searchLatestStripeCustomer
},
customerPortal_customerPortal: customerPortal,
stripeItems_stripeItems: stripeItems
}
in an app
rw-app/src/api/functions/graphql.js
import { stripeSchemas, stripeServices } from 'redwoodjs-stripe/api'
...
export const handler = createGraphQLHandler({
loggerConfig: { logger, options: {} },
directives,
sdls: { ...sdls, ...stripeSchemas },
services: { ...services, ...stripeServices },
onException: () => {
// Disconnect from your database with an unhandled exception.
db.$disconnect()
},
})
Surely theres a better way... makeSchemas
? better package setup? idk