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

Incorporate graphql-resolvers project? #307

Closed
lucasconstantino opened this issue Apr 10, 2017 · 5 comments
Closed

Incorporate graphql-resolvers project? #307

lucasconstantino opened this issue Apr 10, 2017 · 5 comments
Labels
docs Focuses on documentation changes help wanted Extra attention is needed

Comments

@lucasconstantino
Copy link
Contributor

lucasconstantino commented Apr 10, 2017

graphql-resolvers project is basically a single-method-project which facilitates resolver composability. It is, in fact, only a small tool. May be it should live on a wider project such as graphql-tools, may be not.

Any thoughts on that?

@AndrewIngram
Copy link

Can I ask what this library is providing that a more generic functional toolkit (like Ramda) isn't? Mainly because I use Ramda (or sometimes lodash/fp) for composing resolvers and adding branching logic quite regularly and it seems to work fine.

@lucasconstantino
Copy link
Contributor Author

Honestly? It doesn't do anything much different, but I could not find any helper in those library which accomplished exactly what I was looking for. Have you looked into graphql-resolvers's code?

At first I wanted to use Ramda's Left/Right to accomplish what this code does, but truth is most people in JavaScript are not yet used to more profound aspects of functional programming, so they would have a hard time to figure out how to benefit from the lib.

Later, I decided to try and use at least some functional helpers such as composeP, which is a promise enabled version of compose, but I realized composition was not what I was looking for. While composition provide each function with the result of the previous, combineResolvers will call each function with the exact same arguments the resolver provides - root, args, context, and info. Furthermore, one function will only get called if the previous returns a no-result - meaning undefined. All that wrapped in a promise run cycle, meaning throw errors will safely be catched and returned to the graphql execution schema.

@AndrewIngram Does this answer clarify it for you? I've been using some functional toolkit my self and well, graphql-resolvers is just a wrap-up of the ideas and tryouts I had in my projects. I would love to see how you have being doing things on your code too :)

@slightlytyler
Copy link

Would be awesome to have apollo-resolvers and apollo-errors in the graphql-tools project. Their APIs fit in very nicely

@stubailo
Copy link
Contributor

@lucasconstantino I'd love to add a link to this and also companion packages in the docs - please submit a PR if you are still interested, I think it would help people find that project!

We could make a new section on the resolvers page called "companion tools"!

@stubailo stubailo added help wanted Extra attention is needed docs Focuses on documentation changes labels Nov 18, 2017
@stubailo
Copy link
Contributor

I think this is good to close since we added it to the docs. We also have a similar approach with schema directives now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Focuses on documentation changes help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants