-
Notifications
You must be signed in to change notification settings - Fork 61
Resolve params rebase #127
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
Conversation
Seems like this would also solve #82 as well, right? |
I needed something like this and this branch worked very well for me! Are there any plans to get this merged? |
I think there's a definite need for exposing more context to resolvers, e.g. the field, variables and fragments as in this PR. I'm wondering how to do this best though. From an ergonomics-perspective, it's nice that Schema.(field "foo"
~typ:string
~args:[]
~resolve:(fun params src ->
let ctx = ResolveParams.ctx params in
(* ... *)
)
) Also, to align with |
@andreas I think there's definitely some room for improvement, and I would agree that it's important to get right initially what we wanna expose. Happy to bikeshed on naming + what fields can go in.
|
I like the name
Adding a field can in theory be a problem too, but I think it's a minority use case that we can mostly disregard. Changing a field is obviously a problem too.. |
Will do. I don't any other fields I'd like to include at this point. I also looked at graphql-js to see which ones they had when I made the PR.
I didn't list changing a field because that would be a problem in the abstract case too (in case the type changed – if the name of the field changes having an abstract type is an obvious advantage here) |
5472950
to
705b76b
Compare
Just rebased this on master and changed the name from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Could you update README.md
and examples/server.ml
as well please?
examples/server.ml
Outdated
~typ:(non_null user) | ||
~args:Arg.[arg' "intarg" ~typ:int ~default:42] | ||
~resolve:(fun _ctx _intarg -> | ||
~resolve:(fun _params _intarg -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: _info
@andreas nice catch. Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the nitpicking and not being clear in my previous comment: I'd like the idiom to be fun info src -> ...
for resolve functions, i.e. the argument name should be called info
instead of resolve_info
in the README and examples.
That's fine. I'll change it right now. |
Done |
Perfect, thanks! |
This is #82 and https://github.com/andreas/ocaml-graphql-server/tree/resolve-params rebased on current master.
It adds both variables and fragments to the resolve params. I could imagine this having more fields just like in the GraphQL reference implementation:
https://github.com/graphql/graphql-js/blob/26c9874107e65f19576aae0a32638287820f68aa/src/execution/execute.js#L97-L106