Closed
Description
I've read all the docs at graphql.org and the READMEs for graphql-js and express-graphql, and I cannot find a reference for the resolver function signature.
The GraphQL docs suggest:
(obj, args, context)
obj The previous object, which for a field on the root Query type is often not used.
args The arguments provided to the field in the GraphQL query.
context A value which is provided to every resolver and holds important contextual information like the currently logged in user, or access to a database.
But my brief testing with my new express-graphql server I just made (first one) suggests the signature GraphQL.js uses is:
(args, context, obj)
From my console debugging:
JSON.stringify(args) -> { "foo": "bar" }
Object.keys(context) ->
_consuming, baseUrl, method, session,
_dumped, client, next, sessionCookies,
_events, complete, originalUrl, sessionKey,
_eventsCount, connection, params, sessionOptions,
_maxListeners, domain, query, socket,
_parsedUrl, headers, rawHeaders, statusCode,
_passport, httpVersion, rawTrailers, statusMessage,
_readableState, httpVersionMajor, read, trailers,
httpVersionMinor, readable, upgrade,
res, url,
Object.keys(obj) -> fieldName, fieldNodes, fragments, operation, parentType, path, returnType, rootValue, schema, variableValues
(I just learned GraphQL/GraphQL.js last week, so I might be missing something obvious.)