Gqlgen: Adding apollo tracing to api

Created on 9 May 2020  路  6Comments  路  Source: 99designs/gqlgen

I'm struggling to figure out a way to add tracing to gqlgen. Based on the example found here, handler.Graphql is being used but in all recent examples the api is different.

Here's my implementation:

In my handler file

srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{
    Resolvers: &Resolver{
        Store:       store,
    },
}))

return srv

In my api file

srv := graph.NewGraphqlHandler(store, logger)

// modelgen.Middleware is for including dataloaders. This also doesn't seem very clean.

r.Handle("/", graph.NewPlaygroundHandler("/query"))
r.Handle("/query", modelgen.Middleware(store, srv))

Based on digging, I found this issues that might be related: https://github.com/99designs/gqlgen-contrib/issues/19 @vvakame

question

All 6 comments

sorry for late response. I'll be doing something...

@miamollie https://github.com/99designs/gqlgen/blob/master/graphql/handler/apollotracing/tracer_test.go#L33-L35
Here is the new API for apollotracing.
I think you can use it simple add srv.Use(apollotracing.Tracer{}).

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Nope, stale.

I've added this line to my code srv.Use(apollotracing.Tracer{}), but then this is what I see when I call the API:

Screen Shot 2020-09-12 at 12 41 15

An extensions section showed up on the response, but no content on it. What am I missing? (BTW I did tried it with a more complex graphql query, I just simplified it for the screenshot)

@pablote you may need to activate tracing in GraphiQL, on the bottom right.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lynntobing picture lynntobing  路  3Comments

andrewmunro picture andrewmunro  路  4Comments

sumanthakannantha picture sumanthakannantha  路  3Comments

bjm88 picture bjm88  路  4Comments

steebchen picture steebchen  路  3Comments