graphiti_old_archived icon indicating copy to clipboard operation
graphiti_old_archived copied to clipboard

[POC] Allow Graphiti usage for api requests to be optional

Open caseyprovost opened this issue 5 years ago • 1 comments

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)

  • Look for an instance variable defined in the controller and render conditionally (something like @graphiti_controller == true
  • Introduce libary configuration that is used at render time. (Something like Graphiti.config.strict) which would only manipulate requests/params/etc if the current route was in Graphiti's api_namespace.
  • Alter Graphiti so that it only manipulates requests under it's defined 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

  • Graphiti currently only supports a singular api_namespace. So if someone was building an API under /v1 and then added another API version under /v2 which also used Graphiti...then the second version would run into a problem.

caseyprovost avatar Nov 20 '18 16:11 caseyprovost