graphiti-api / graphiti-rails

MIT License
53 stars 28 forks source link

Don't set `format` when parsing parameters #72

Open wagenet opened 3 years ago

wagenet commented 3 years ago

Setting the format in parameters has a special behavior in Rails. One side effect is respond_to will now ignore any provided Accept header in favor of the provided format. The default Rails json parser doesn't set format and it doesn't seem to me that we need to set it either.

https://github.com/graphiti-api/graphiti-rails/blob/c557ca44b5b9930c2c7023e4d7503dcba0fe8e56/lib/graphiti/rails/railtie.rb#L65

wagenet commented 3 years ago

Also, is there any reason why we shouldn't just use the same behavior as the built-in json handler?

richmolj commented 3 years ago

I think this is so users can pass in a normal application/json instead of application/vnd.api+json and still get JSON:API rendered. Originally because it's a hurdle to get up and running quickly for new users, at this point it's more for backwards-compatibility.

If you can accomodate that use case and everything still seems to be working correctly I'm 👍

wagenet commented 3 years ago

I changed it and no tests failed, so not sure.

richmolj commented 3 years ago

Yeah I am just not sure. That block was originally copied from jsonapi-rb I know, but I think I added the format part.

I'm mentally 👍 but just kinda scared :/