Skip to content

Makes singleton resources finding with an id work#447

Merged
jkeen merged 8 commits into
graphiti-api:masterfrom
doublevoid:patch-singleton-resource
Mar 18, 2024
Merged

Makes singleton resources finding with an id work#447
jkeen merged 8 commits into
graphiti-api:masterfrom
doublevoid:patch-singleton-resource

Conversation

@doublevoid

Copy link
Copy Markdown
Contributor

Creating a resource, setting a primary endpoint, and then using ResourceName.find({id: id}) doesn't work if the controller is set up as a show action.
You get ResourceName cannot be called directly from endpoint /api/v1/resource#show!

This is why.
A workaround is to either go with self.validate_endpoints = false or change the action to be an index action, which bypasses the stripping of a would-be id.

This PR changes the behavior to only strip the id from path if the id is actually in path!

@jkeen jkeen merged commit e1dd811 into graphiti-api:master Mar 18, 2024
github-actions Bot pushed a commit that referenced this pull request Mar 18, 2024
## [1.5.3](v1.5.2...v1.5.3) (2024-03-18)

### Bug Fixes

* leverage ruby-2.7 parameter forwarding ([#431](#431)) ([ae09a46](ae09a46))
* prevent :id stripping when :id not in path ([#447](#447)) ([e1dd811](e1dd811))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.5.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

jkeen pushed a commit to jkeen/graphiti that referenced this pull request Mar 27, 2024
Address edge case where ResourceName.find({id: id}) would error if controller was set up as a show action
jkeen pushed a commit to jkeen/graphiti that referenced this pull request Mar 27, 2024
## [1.5.3](graphiti-api/graphiti@v1.5.2...v1.5.3) (2024-03-18)

### Bug Fixes

* leverage ruby-2.7 parameter forwarding ([graphiti-api#431](graphiti-api#431)) ([ae09a46](graphiti-api@ae09a46))
* prevent :id stripping when :id not in path ([graphiti-api#447](graphiti-api#447)) ([e1dd811](graphiti-api@e1dd811))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants