[POC] Allow Graphiti usage for api requests to be optional#53
[POC] Allow Graphiti usage for api requests to be optional#53caseyprovost wants to merge 35 commits intographiti-api:masterfrom caseyprovost:master
Conversation
richmolj
left a comment
There was a problem hiding this comment.
I think we need the MIME type to be configurable, where jsonapi is the default and graphiti is the override. But otherwise this looks great - apologies for the delay, I really appreciate your hard work and follow-though on this. It is a big help ❤️ !
| klass.new(@_exposures.merge(object: obj, resource: resource)) | ||
| end | ||
|
|
||
| if resources.nil? || Array(resources)[0].instance_variable_get(:@__graphiti_resource) |
There was a problem hiding this comment.
Can we do resources = Array(resources) here so we don't have to do it further down the line?
|
|
||
| if Mime[:jsonapi].nil? # rails 4 | ||
| Mime::Type.register('application/vnd.api+json', :jsonapi) | ||
| if Mime[:graphiti].nil? # rails 4 |
There was a problem hiding this comment.
I think it is OK to make this a configuration option, but not a default. The majority of our users do not run both gems at the same time, and I think :jsonapi makes a lot more sense for these users. Could we make this configurable?
|
@caseyprovost this library has moved to https://github.com/graphiti-api/graphiti - it's the same code, but would you mind recreating the PR there? Looking through the comments I think we're almost there and I'd love to get this in. |
Add around_persistence
Goal
At the moment this library does not play nice when using an API already built on JSONAPI Rails. This is because it includes this gem and overrides some default behavior. It would be AMAZING if this library could run along side the jsonapi-rails gem!
How (options & ideas)
@graphiti_controller == trueGraphiti.config.strict) which would only manipulate requests/params/etc if the current route was in Graphiti's api_namespace.Approach
I opted for altering the library code to make its inclusion in projects a little easier. The idea here is that if someone is creating an API or a new version and are already using some of the dependent gems in this project...there is no conflict (other than gem version potentially).
Problems With Approach
/v1and then added another API version under/v2which also used Graphiti...then the second version would run into a problem.