interledger / rafiki

An open-source, comprehensive Interledger service for wallet providers, enabling them to provide Interledger functionality to their users.

Home Page:https://rafiki.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate Shared Apollo Client

BlairCurrey opened this issue · comments

Look into a shared apollo client that could be used across our packages and published on npm. Do not include actual requests. Should consist of common configuration (including authLink for signing requests) and GQL types.

Things to consider:

  • how to handle publishing on npm and gql versions?

After looking into this more I don think there is really much shared setup that we want to package together and share everywhere. Here are the things that we thought about including in the package and what I or we concluded about them:

  • common configuration. This includes the auth link and probably not much else. Other than that there are some no-fetch cache settings but I don't we want to enforce that centrally and that should be set where its used.
  • requests. Several people noted they wanted to be able to form these where called, which I agree with so you can specify certain fields and generally call as needed
  • graphql schema, instead of generating/outputting to several packages. This seemed like a good idea but kind of goes hand-in-hand with requests. If we are forming requests where the client is used, then we need to use the graphql types there. I considered putting in a shared client package and exporting for use where we make requests but we currently dont actually generate the same thing everywhere (different packages generate the gql types differently).

Really the only non-trivial thing that seems worth sharing between packages is the auth link and we decided copy-pasting between the few places we use it is fine.

Thanks for the overview, @BlairCurrey! One question, what do you mean exactly by

(different packages generate the gql types differently).

If you look at https://github.com/interledger/rafiki/blob/main/packages/backend/codegen.yml and ../frontend/app/generated/graphql.ts: for example you'll see some options which are not enabled elsewhere ('typescript-operations' plugin, omitOperationSuffix). Thus I'm not sure that we can/should generate 1 thing and use everywhere. Although I havent looked too deeply into these differences. Even if we can and do want to standardize on 1 generated output, I'm not sure that its better to generate into an internal package and use that package everywhere. Just directly outputting where its used seems more direct.