Skip to content

Custom servlet listener with graphql-spring-boot-starter #240

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

Closed
matheus1lva opened this issue Apr 2, 2020 · 5 comments
Closed

Custom servlet listener with graphql-spring-boot-starter #240

matheus1lva opened this issue Apr 2, 2020 · 5 comments
Labels

Comments

@matheus1lva
Copy link

Hello!

I'm using graphql-spring-boot-starter and i'm trying to add a custom sevlet to it but docs are a little missleading and i can't find the best place to put it!

I just want to add custom info to the context!

How could i do it! Thank you!

@oliemansm
Copy link
Member

The subject and body of your question aren't very clear and seem to be asking different things. You mention that "you just want to add custom info to the context".

See #226 how to do that.

@matheus1lva
Copy link
Author

So in graphql there is the concept of contexts, which can have any data on data, to be retrieved on any mutation or resolver. I was looking on how to do that!

@oliemansm
Copy link
Member

Right, so that's why I pointed you to #226 (comment). Did you take a look at that? The custom context class you define there can contain any properties you want to pass around and you can get a hold of it in resolvers by using the DataFetchingEnvironment which can exist as the last argument of any resolver method, i.e.:

void myQueryMethod(int argOne, String argTwo, DataFetchingEnvironment env) {
  MyCustomContext context = (MyCustomContext) env.getContext();
  Thing myThing = context.getThing();
  
}

@oliemansm
Copy link
Member

Can you confirm whether this answered your question so we can close the issue?

@oliemansm
Copy link
Member

Closing the issue due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants