-
Notifications
You must be signed in to change notification settings - Fork 7
Allow root_value to be passed along to GraphQL.execute #9
Conversation
Updating example schema to match latest revisions.
test/graphql/plug/endpoint_test.exs
Outdated
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.
The callback needs to be in the same {module, function} format as the schema otherwise Phoenix code reloading messes with it.
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.
A note regarding this, currently the function is being pulled out and executed in the init function for grabbing the schema. For this function, I will need to make the evaluation and execution happen in call instead. Otherwise, we would never execute it per request or get the conn reference.
|
Thanks for the PR! See comments, but otherwise looks great. |
|
I'm adding the comments and have most of them addressed. Do you prefer getting it rebased into a single commit, or do you want to see a new commit? |
|
Not too fussed about squashing commits, but this will need to be rebased on top of the new changes. Sorry I couldn't get this merged in before I refactored things. Ping me on Slack if you need a hand or have any questions. The other thing that is missing is variables, which is pretty much the same as |
During plug initialization, allows a function to be defined that will take a conn as input and then return a data structure that can be used as the root_value into the GraphQL.execute method.
lib/graphql/plug/endpoint.ex
Outdated
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.
just match nil no guard needed
lib/graphql/plug/endpoint.ex
Outdated
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.
specify arity 1 in is_function
|
Awesome thanks again! |
Allow root_value to be passed along to GraphQL.execute
During plug initialization, allows a function to be defined that will
take a conn as input and then return a data structure that can be
used as the root_value into the GraphQL.execute method.