You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm adding partykit (websocket) to my project, and when a mutation happens, I'm sending a message to my ws server to broadcast my update to my clients (for other users to receive the update).
I'm using nextjs so can't really use the smart subscriptions.
I was wondering if there's some utility function to convert my data (coming from stripe api) onto the my pothos object implementation so i matches my graphql format.
This may involve writing a plugin maybe but curious if there's some function that will do that already.
Here's a snippet of what I'm trying to do:
// Schema definitionexportconstStripeAccount=builder.objectRef<Stripe.Account&{spaceId: string}>('StripeAccount').implement({fields: (t)=>({id: t.field({type: 'ID',resolve: (account)=>encodeGlobalID('StripeAccount',account.spaceId),}),accountId: t.exposeID('id'),chargesEnabled: t.exposeBoolean('charges_enabled'),detailsSubmitted: t.exposeBoolean('details_submitted'),payoutsEnabled: t.exposeBoolean('payouts_enabled'),requirements: t.field({type: ['String'],resolve: async(account)=>account.requirements?.currently_dueasstring[]??[],}),name: t.field({type: 'String',nullable: true,resolve: (account)=>{returnaccount.business_profile?.name??account.settings?.dashboard?.display_name??'Unknown';},}),isOnboardingComplete: t.field({type: 'Boolean',resolve: (account)=>{returnaccount.details_submitted&&account.charges_enabled&&account.payouts_enabled;},}),}),});// Mutationbuilder.mutationField('updateStripeAccount',(t)=>t.field({authScopes: {admin: true,space: 'owner',},type: StripeAccount,nullable: true,args: {...},asyncresolve(_root,_args,{ decodedSpaceId, spaceId }){// Update the stripe accountconstaccount=awaitstripe.accounts.retrieve(id);// Websocket callfetch(`http://127.0.0.1:1999/parties/spaces/${spaceId}`,{method: 'POST',headers: {'Content-Type': 'application/json',},body: JSON.stringify({type: 'stripeAccount:update',data: account,// this is where I'd wanna convert from stripe schema to StripeAccount schema defined above}),});return{
...account,spaceId: space.id,};},}),);
The text was updated successfully, but these errors were encountered:
I'm adding partykit (websocket) to my project, and when a mutation happens, I'm sending a message to my ws server to broadcast my update to my clients (for other users to receive the update).
I'm using nextjs so can't really use the smart subscriptions.
I was wondering if there's some utility function to convert my data (coming from stripe api) onto the my pothos object implementation so i matches my graphql format.
This may involve writing a plugin maybe but curious if there's some function that will do that already.
Here's a snippet of what I'm trying to do:
The text was updated successfully, but these errors were encountered: