-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Feature Request: Adding resolve method to new schema language #499
Comments
We have a package for this that we and some other companies have been using in production for a while, I think it's exactly what you're looking for, and even supports unions/interfaces, custom scalars, etc. See an example here: https://github.com/apollostack/graphql-syntax#graphql-tools Full docs here: http://dev.apollodata.com/tools/graphql-tools/generate-schema.html (although a bit outdated) See a full example server here: https://github.com/apollostack/GitHunt-API/blob/master/api/schema.js |
@achakravarty For more context: the resolvers aren't part of the GraphQL schema language, because they are implementation specific. Resolve functions contain code, which will look different in Python, Scala, Go, etc. The schema language is independent of the implementation. |
@helfer Makes sense. But given that, I was wondering whether it would make sense to support a syntax that allows defining resolve methods and binding them separately like it does in grapql-tool as mentioned my @stubailo For example: type User {
name: getName(user: User) : String //here getName is a function that would take a user and return a String.
} And build a way to attach a resolve method, ideally based on convention eg. resolvers: {
User: {
getName: (user) => { return "Mr." + user.firstName + ' ' + user.lastName; }
}
} And finally be able to bind them to the schema as: schema.buildSchema(`
type User {
name: getName(user: User) : String
}
`)
.withResolvers(resolvers); |
@achakravarty yeah, that's basically what graphql-tools does for javascript. It has a function called |
@helfer Cheers! Will refer that then. You can close this issue. |
I am fairly new to GraphQL and quite like the new schema language. I was just wondering why the resolve method is not a part of the it. It would be really awesome if there was a feature that would allow the resolve functionality to work with the new schema. Thanks
The text was updated successfully, but these errors were encountered: