Git Product home page Git Product logo

Comments (12)

apottere avatar apottere commented on June 28, 2024

The GraphQL object is request-scoped, so it's created on every request. You'll need to implement a https://github.com/graphql-java/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/InstrumentationProvider.java bean that returns the tracing instrumentation.

from graphql-spring-boot.

flarepass avatar flarepass commented on June 28, 2024

Hi @apottere,
Thank you for your response, but I have create an implementation of the InstrumentProvider :
public class GraphQLInstrumentationProvider implements InstrumentationProvider { @Override public Instrumentation getInstrumentation() { return new TracingInstrumentation(); } }

and I also provide the bean,
@Bean InstrumentationProvider instrumentationProvider() { return new GraphQLInstrumentationProvider(); }

I'll try to include some detail of my sample code :

my schema only contain

type Query { allLinks: [Link] } type Link { id: ID! url: String! description: String }

my request :
{ allLinks{ id } }
my response :
{ "data": { "allLinks": [ { "id": "1" } ] } }

Is there anything else that i missed ?

from graphql-spring-boot.

apottere avatar apottere commented on June 28, 2024

No, that should work. Is it injecting the InstrumentationProvider into your servlet?

from graphql-spring-boot.

flarepass avatar flarepass commented on June 28, 2024

Hi @apottere ,

I think it suppose to provide the InstrumentationProvider bean to the servlet, but as i see in the documentation, http://graphql-java.readthedocs.io/en/v6/instrumentation.html

The instrumentation should be set into the GraphQL object, that's why at first i tried to create the bean for GraphQL object, but since the GraphQL object is request-scoped, i'm not sure how to add it.

from graphql-spring-boot.

apottere avatar apottere commented on June 28, 2024

The GraphQL object is created by the servlet when it gets a request.

from graphql-spring-boot.

flarepass avatar flarepass commented on June 28, 2024

Hi @apottere,

I'm still unable to provide the TracingInstrumentation to the GraphQL object.
I have created my implementation and provide the Bean.

could you give me example of how to injecting the Instrumentatio Provider?
or Is it possible to keep this issue open so I can get insight from some people that has tried this before?

Thank you

from graphql-spring-boot.

apottere avatar apottere commented on June 28, 2024

Sorry, I was mistaken - you can just add your instrumentation as a bean and it should be picked up:

@Bean
Instrumentation instrumentation() {
    return new TracingInstrumentation();
}

from graphql-spring-boot.

flarepass avatar flarepass commented on June 28, 2024

hi @apottere ,

Did that work for you ?
Since i have tried it, i also have tried provided the TracingInstrumentation as bean before, but there is no change at all.

from graphql-spring-boot.

apottere avatar apottere commented on June 28, 2024

Yes, I tried it in an example project and hit a breakpoint in the TracingInstrumentation

from graphql-spring-boot.

flarepass avatar flarepass commented on June 28, 2024

Hi @apottere

Yes, I also tried to debug and hit a breakpoint at GraphQLWebAutoConfiguration which the Tracing Instrumentation has been added to GraphQLServlet bean.
Yet there is no change to my Json Response, there is no extra tracing data under extensions.
Thank you 👍

from graphql-spring-boot.

flarepass avatar flarepass commented on June 28, 2024

Fixed,
It's because of older version of version of graphql-java-servlet as pointed by eric taix at Stackoverflow 😅
Thank you

from graphql-spring-boot.

kwang1 avatar kwang1 commented on June 28, 2024

Sorry, I was mistaken - you can just add your instrumentation as a bean and it should be picked up:

@Bean
Instrumentation instrumentation() {
    return new TracingInstrumentation();
}

Hi @apottere , can this be found in any documentation? are there any detailed documents about which beans can be injected to Spring?

Thanks.

from graphql-spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.