Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InsertBefore argument for add() #5

Open
sminnee opened this issue Sep 20, 2020 · 2 comments
Open

InsertBefore argument for add() #5

sminnee opened this issue Sep 20, 2020 · 2 comments

Comments

@sminnee
Copy link
Owner

sminnee commented Sep 20, 2020

To provide some control of the order in which callbacks are called, add an "insert before" argument to add().

Questions:

  • should you be able to provide multiple options for insert before, and it will insert before the first one that is found?
  • if none are found, should it append to the end of the list or throw an error? If the former it provides a more open-ended way of building up an ordering...
@sminnee
Copy link
Owner Author

sminnee commented Sep 20, 2020

@unclecheese this came from your comments - do you have some examples of how/why you want to adjust callback ordering in graphql resolvers?

@unclecheese
Copy link

Sure. In GraphQL 4, there's another layer of abstraction, "plugins" which are ordered and can order middleware by proxy.

So you have something like:

plugins:
  somePlugin:
    before: anotherPlugin
  anotherPlugin:
    after: somethingElse
  finalPlugin:
    after: '*'

Each of those plugins gets to call ->addResolverMiddleware(), so the order of the middlewares is implicitly set by the order of the plugins. For this library, you'd be looking at just removing that second layer of abstraction.

https://github.com/silverstripe/silverstripe-graphql/blob/cedacb79929745bd1d49bf9309e68c7679c7a90e/src/Schema/Plugin/PluginConsumer.php#L150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants