I want to pass on a query string ?parameter_foo=bar to my /jsonapi endpoint but I was hoping to see that query string on the link section so that, in my case gatsby, can follow up child links with the same parameter.
I worked around this on gatsby with an interceptor, but as requested on Slack, posting the bug/question here.
It doesn't seem as a cache issue.
Comments
Comment #2
gabesulliceI'm conflicted about whether this is a bug report or a feature request. Since the spec says:
I therefore think this is a bug report.
If the query parameter is valid, I think we should ensure that it's mirrored in top-level
selflink.@hanoii, would the above solve your need?
If the query parameter also needs to be mirrored in
nextandpreviouslinks of the response document I think this becomes more of a feature request.Comment #3
hanoiiFor some reason I don't have next and previous on my json on any entity (!?), but I'd say all.
On the root `/jsonapi` I would need the query string on every sub entity type, so that gatsby can properly follow all links with the same query string, so it seems it's not just `_self`.
Comment #4
hanoiiAdding organization
Comment #5
wim leersThat only happens for resource collections, not for individual resources. So for example, you should see them on
/jsonapi/node/article, but not on/jsonapi/node/article/UUID.What is the rationale behind this? What does this query parameter convey? Because for example a
?filterquery parameter's value usually only makes sense for a particular resource type (e.g.node--article), not for all resource types.Comment #6
wim leersPer #3, I think this is clearly a feature request.
Comment #7
wim leersComment #8
hanoiiMy use case is a typical (mostly) microsite approach. The driver for each microsite is a taxonomy term that is present exclusively on the content types. A goal for this project was to keep the drupal part as easy as possible, both in terms of admin and in terms of maintainability/development. Less fields, less entities nesting, less complex options in favor of more concrete and flexible coding approaches. So I have content types that have paragraphs that have other related entities as medias. Also I wanted to avoid mulit-site if at all possible. Entity access, although still an option, I still think, IMO, that adds unnecessary complexity.
I use this for Gatsby, so Gatsby needs to pulls the content for each microsite. So far I have been pulling everything and doing the filtering on gatsby's graphql side, which is OK, but to take advantage of some design decisions on gatsby and to prevent each microsite taking a lot to build once there's enough content in there I rather just make sure that jsonapi only outputs what the microsite needs.
So my rationale is to give gatsby the follwing URL for the jsonapi backend:
https://www.example.com/jsonapi?micro_site=TIDI am already successfully altering the queries to properly filter what I need with hook_query_TAG_alter() as mentioned on #3023444: Add a query tag to the entity query for other modules to perform alterations, but gatsby crawls all subsequent entities without this query string, as it follows what comes out of the initial `/jsonapi`.
I hope this helps.
I have a workaround in place with an interceptor on the gatsby request that appends this query string to every URL, I just `expected` that the querystring would be there.
Comment #9
hanoiiAnd just to note something on the titile, I wonder if it's just the entry point, and not every single URL generated on the `_links` section of every endpoint.
Comment #10
wim leersThe reason we originally did not mirror those query arguments is simple: it destroys our cacheability.
Right now we only respect and therefore vary by the officially supported URL query parameters. If we mirror them, we need to support them all.
Comment #11
gabesulliceHaving read the reasoning, I think the use case is sound and that enabling this kind of functionality is worth doing. However, I don't think the original concept I had of "mirroring" the query parameter is the right way to do it.
Instead, I think the "right" approach for us to take is to enable link customizations by landing #2995960: Add a Link and LinkCollection class to support RFC8288 web linking. and then using the JSON:API Hypermedia module (experimentally) to alter the
selflinks that already exist. That alteration can be based on the current microsite context. Then, the cache will not need to vary by random query parameters, it will instead vary by a cache context for the "active microsite" that would be added to the altered links.Comment #12
wim leersPer #11.
Comment #13
wim leers#2995960: Add a Link and LinkCollection class to support RFC8288 web linking. landed!