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

Make graphql url possible to cache #34

Open
jonaskello opened this issue Nov 1, 2021 · 0 comments
Open

Make graphql url possible to cache #34

jonaskello opened this issue Nov 1, 2021 · 0 comments

Comments

@jonaskello
Copy link
Member

jonaskello commented Nov 1, 2021

Current situation

Today we use a graphql url that points to the marker, eg.

https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b/production

Using graphql persistent queries it is possible to make GET requests using URLs that are possible to cache in the web browser. However this is only possible if the URL always returns the same result for the same queries.

When using the marker in the URL that is not true because the marker can point to different releases at different points in time. So in that case the client always needs to make a request to see if the query result is modified. We can use etag and 304 Not Mofified responses to optimize this but still a request has to be made.

Proposed new situation

If we changed the marker in the URL and used the release id instead, the URL would be possible to cache fully as it would always return the same result for the same query.

To do this we need a way to map marker_name-->release_id. This mapping could be returned if you don't specify the trailing markername/release_id

Today, if you don't specify marker you get a list of possible markers, eg for

https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b

you get this:

[
  "https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b/staging",
  "https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b/produktion"
]

We could change that into this:

{
  "staging": "https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b/{release_id}"
  "produktion": "https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b/{release_id}"
}

where {release_id} would be the actual id of the release.

Compability and breaking changes

In order to keep combability we could still offer the same URL as before with the markername suffix instead. Then these URLs would map to the same endpoint:

https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b/staging
https://public-api.promaster.se/graphql/7290ba61-a9a0-4786-9253-5b70cd83ca6b/{current_release_id_for_staging_marker}

The result of calling the url without the markername suffix would be a breaking change, however I think no applications do this?

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

No branches or pull requests

1 participant