- Issue created by @bstan
- Merge request !79Provide a version parameter to entity by id queries to provide the latest or... β (Closed) created by bstan
- π¦πΊAustralia almunnings Melbourne, π¦πΊ
Apologies for the 2.2.x dev spam, fumbling around in CI to get Drupal 11 support tested.
Please assign me in gitlab for a review once you're happy with it.
- πΊπΈUnited States bstan
@almunnings I dont seem to have the ability to add a reviewer, but this MR is ready for review.
- π¦πΊAustralia almunnings Melbourne, π¦πΊ
Just a hunch, but I suspect people might get a bit more use out of this with opening up the input to be a String, rather than an Enum.
We could load in by revision ID then.
WORKING_COPY also seems redundant, as it's the same as providing no value.
So I'm kind of leaning into:
- Change input arg to String
- Remove Enum
- Rename "Version" to "EntityRevision"
- Check for "latest" or attempt to load revision by arg value.
- Integrate graphql Buffer `EntityRevisionBuffer` to do the loadingIf you're cool with that, I can have a refactor this weekend.
- π¦πΊAustralia almunnings Melbourne, π¦πΊ
almunnings β changed the visibility of the branch 2.2.x to active.
- π¦πΊAustralia almunnings Melbourne, π¦πΊ
almunnings β changed the visibility of the branch 2.2.x to hidden.
- πΊπΈUnited States bstan
Yeah, this works for me, I went back-and-forth on the Enum versus String but went the Enum route since it allow for input to be "fixed" to 2 options.
With that said, I would prefer to keep a value to just get the working copy in the event the revision id is not available. This helps logically with a decoupled frontend, for example:
// Next.js const { isEnabled } = draftMode() const query = gql` query($id: String, $revision: String) { node(id: $id, revision: $revision) { .... } } ` await someGraphQLClient.query({ query, variables: { id, revision: isEnabled ? 'working-copy' : '' }
- Status changed to Needs review
7 months ago 11:46pm 20 May 2024 - π¦πΊAustralia almunnings Melbourne, π¦πΊ
@bstan Did you want to run your eyes over https://git.drupalcode.org/project/graphql_compose/-/merge_requests/80 please
I think it'll cover your use case.
Added in some junk code, but it'll do nicely:
/** * The latest revision identifiers. */ const REVISION_LATEST = [ 'latest', 'newest', 'working', 'working-copy', ]; /** * The current revision identifiers. */ const REVISION_CURRENT = [ 'active', 'current', 'default', ];
So you should be able to do:
node(id: 123, revision: 'working-copy') {} // or latest, newest, working node(id: 123, revision: 'current') {} // or active, default node(id: 123, revision: 456) {} node(id: 123) {}
Have a go, let me know!
- π¦πΊAustralia almunnings Melbourne, π¦πΊ
Iβll take it onboard though. It can be reworked to only request once.
- π¦πΊAustralia almunnings Melbourne, π¦πΊ
I guess we need to make a decision.
If lang code is requested, and latest is requested, and there is no latest revision for that language⦠null ok?
Seems logical
Although we might not even make it here, as the entity load with language could also fail if there was no revision.
I might make a test today and just set this in stone
- Status changed to Fixed
7 months ago 11:46am 28 May 2024 - π¦πΊAustralia almunnings Melbourne, π¦πΊ
Merged into 2.2-dev, no plans to back port at this stage.
Thanks!
Automatically closed - issue fixed for 2 weeks with no activity.