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

Investigate Shared Apollo Client #2706

Closed
BlairCurrey opened this issue May 7, 2024 · 3 comments
Closed

Investigate Shared Apollo Client #2706

BlairCurrey opened this issue May 7, 2024 · 3 comments
Assignees
Labels
discussions: ideas Convert to an idea discussion

Comments

@BlairCurrey
Copy link
Contributor

BlairCurrey commented May 7, 2024

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?
@BlairCurrey BlairCurrey added the discussions: ideas Convert to an idea discussion label May 7, 2024
@BlairCurrey BlairCurrey changed the title Start Common Library Investigate Shared Apollo Client May 7, 2024
@BlairCurrey BlairCurrey self-assigned this May 14, 2024
@BlairCurrey
Copy link
Contributor Author

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.

@mkurapov
Copy link
Contributor

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

(different packages generate the gql types differently).

@BlairCurrey
Copy link
Contributor Author

BlairCurrey commented May 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussions: ideas Convert to an idea discussion
Projects
Status: Done
Development

No branches or pull requests

2 participants