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

feat: persisted operations #44

Closed
wants to merge 5 commits into from
Closed

feat: persisted operations #44

wants to merge 5 commits into from

Conversation

JoviDeCroock
Copy link
Contributor

@JoviDeCroock JoviDeCroock commented Dec 4, 2023

Resolves #35

This adds a way to adopting persisted-operations within fuse, this leverages an exchange to take the pre-computed documentId from the document and sends it for mutations/queries. When we see queries the exchange will cast this to a GET operations to improve browser cache-ability of operations.

This is focussed currently on the Next.js way where we have our datalayer co-located with our front-end. This does not facilitate mobile/... clients yet, to do so we might need to expand the options of our route-handler to fetch persisted hashes from a Key-value store. We could facilitate pushing to i.e. Redis/... in a CLI and then configure our GraphQL endpoint to pull from there when a hash comes in.

Something that I would still like to improve here is the fact that you need to manually pass in the .json file. I was thinking that this could maybe be a fairly automatic adoption journey where you are opted into this automatically and need to opt-out explicitly.

Would be eager to hear peoples thoughts here

Personally I gravitate towards supporting a K/V store like Redis, ... or the JSON file for the simple case where we only have i.e. a co-located Next.JS application 😅 added an example how it could look like with vercel/kv

One downside here is that our codegen relies on the server running which could be a cascading effect when you import the persisted operations json but it doesn't exist yet 😅

Copy link

vercel bot commented Dec 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fusejs-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 8, 2023 1:57pm
spacex-fuse ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 8, 2023 1:57pm

url:
process.env.NODE_ENV === 'production'
? 'https://spacex-fuse.vercel.app/api/fuse'
: 'http://localhost:3000/api/fuse',
exchanges: [cacheExchange, ssr, persistedExchange, fetchExchange],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add this as an option rather than having folks specify exchanges I reckon

@JoviDeCroock
Copy link
Contributor Author

JoviDeCroock commented Jan 4, 2024

Closing this for the time being but I do want to work this out eventually

@JoviDeCroock JoviDeCroock deleted the trusted-documents branch February 1, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Trusted Documents/Persisted Operations
1 participant