-
In the GraphQL-Ruby documentation examples, there are many examples referring to the In the example for integration tests for Transport-level behaviors: it "loads user token into the viewer" do
query_string = "{ viewer { username } }" Is I am thinking it's the former, because I believe the controller is the sole source of the context object, and that it is never returned in the JSON. (Can you even query the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In that example, it's imagined that class Types::Query
field :viewer, User
def viewer
context[:current_user]
end
end That is, a field on the |
Beta Was this translation helpful? Give feedback.
In that example, it's imagined that
viewer
is this:That is, a field on the
Query
type that returns the currently-authenticated user, if there is one. This convention started with Relay.js, which, IIRC, required such a field to be implemented. At least GitHub's API still has a field like that.