Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way to export services #72

Open
chrisvdm opened this issue Jan 24, 2023 · 1 comment
Open

Better way to export services #72

chrisvdm opened this issue Jan 24, 2023 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed important internal label

Comments

@chrisvdm
Copy link
Owner

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

@chrisvdm chrisvdm added enhancement New feature or request help wanted Extra attention is needed important internal label labels Jan 24, 2023
@chrisvdm
Copy link
Owner Author

chrisvdm commented Feb 2, 2023

Seems to be an issue with parcel a little bit re exporting from api side of plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed important internal label
Projects
None yet
Development

No branches or pull requests

1 participant