graphiti-api / graphiti

Stylish Graph APIs
https://www.graphiti.dev/
MIT License
983 stars 140 forks source link

Improve InvalidEndpoint Error #149

Open richmolj opened 5 years ago

richmolj commented 5 years ago

Should link to documentation and the self.validate_endpoints = false escape valve

leomeloxp commented 3 years ago

For anyone arriving at this issue and wondering which documentation you should be looking at. I believe this is the relevant one: https://www.graphiti.dev/guides/concepts/links.

The related code that you should be checking are likely to be https://github.com/graphiti-api/graphiti/blob/v1.2.39/lib/graphiti/resource/interface.rb#L53-L55 and https://github.com/graphiti-api/graphiti/blob/v1.2.39/lib/graphiti/resource/links.rb#L74-L83

I'm not very well versed in Ruby but it seems to me that the checks in allow_request? forces an undocumented scenario where if your request is one of [:update, :show, :destroy], it must also include an id as a param.

I arrived at a scenario where that was not the case (whilst appreciating it's not very standard) and had this error having me scratching my head for quite some time 😅