Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KieronWiltshire/2ae1e7df9e6e50432e42769f0d0d3506 to your computer and use it in GitHub Desktop.
Save KieronWiltshire/2ae1e7df9e6e50432e42769f0d0d3506 to your computer and use it in GitHub Desktop.
plugin A = returns {
  user {
    email
  }
  post {
    text
  }
}

plugin B = returns {
  user {
    email
  }
  post {
    test
  }
}

So either one of these can be used with the front-end (GREAT_ exactly what I want, okay?)

plugin C = tries to override "user" internally

So now when the front-end tries to query "user" it will return whatever C has defined. The issue is, I may require plugin A, and plugin C. So user has to be declared twice. ITS HAS TO BE DECLARED TWICE.

So now my design proposal is the example below, however this breaks GraphQL's core principles, as the goal is to be able to retrieve any piece of data.

http://someplugin.com/q/pluginA/?query={ user, post } // this will work
http://someplugin.com/q/pluginB/?query={ user, post } // this will work
http://someplugin.com/q/pluginC/?query={ user } // this will work

http://someplugin.com/q/pluginC/?query={ user, post } // this wont work

So my question is, to I keep this and require front-end specific plugins to query based on namespace, however if a front-end plugin requires pluginA as a namespace, the front-end plugin would have to be configured to use pluginB if something changes, even though Plugin A and B are both compatible, kind of makes it tedious to change the configuration each time you swap an implementation imo

Or maybe, do I have something like this:

http://someplugin.com/q/?query={ pluginA.user, pluginA.post } // this will work
http://someplugin.com/q/?query={ pluginB.user, pluginB.post } // this will work
http://someplugin.com/q/?query={ pluginC.user } // this will work

http://someplugin.com/q/?query={ pluginC.user, pluginA.post } // this will now work

But again, this has to be configured to use the namespace, but instead this time on the queries themselves, however this does have the advantage of exposing ALL end points, but a lot less cleaner. So basically I want to know is there another way? or otherwise, what is your preference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment