Skip to content
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

Add resolver middleware Add opentracing support #77

Merged
merged 6 commits into from
Apr 6, 2018
Merged

Conversation

vektah
Copy link
Collaborator

@vektah vektah commented Apr 5, 2018

Adds a user specified resolver middleware stack and some opentracing resolver middleware that uses it.

The middlware stack probably goes a long way towards #39, allowing middlware to be defined around the user defined resolvers. It will not be called around any directly bound models fields or methods.

example usage:

	http.Handle("/query", handler.GraphQL(starwars.MakeExecutableSchema(starwars.NewResolver()),
		handler.Use(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
			rc := graphql.GetResolverContext(ctx)
			fmt.Println("Entered", rc.Object, rc.Field.Name)
			res, err = next(ctx)
			fmt.Println("Left", rc.Object, rc.Field.Name, "=>", res, err)
			return res, err
		}),
	))

weakly typed interface but there is an assertion in the generated code as soon at it returns. This is mostly to allow access to the error on the way through. Unmarshaled args are now in resolver context, and can be manipulated before calling next.

The dataloader example now hosts an appdash instance to see the metrics collected. Here is an example of running

query {
  customers {
    name
    address {
      street
    }
    orders {
      date
      items {
        name
      }
    }
  }
}

image

@vektah vektah merged commit 4d2eece into master Apr 6, 2018
@vektah vektah deleted the opentracing branch April 6, 2018 01:07
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
Add resolver middleware Add opentracing support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant