Skip to content

RootValue equivalent in graphql-go #102

@stanonyime

Description

@stanonyime

In the express-graphql implementation there is an example of how to pass addition variables to the resolve function in the rootValue key. Example:

app.use('/graphql', graphqlHTTP(request => ({
  schema: MySessionAwareGraphQLSchema,
  rootValue: { session: request.session },
  graphiql: true
})));

The session value is then accessed in the resolve function of a schema type:

new GraphQLObjectType({
  name: 'MyType',
  fields: {
    myField: {
      type: GraphQLString,
      resolve(parentValue, _, { rootValue: { session } }) {
        // use `session` here
      }
    }
  }
});

Is there any documentation/example on how to pass and access root values from resolve functions in graphql go?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions