Skip to content

GraphQLJavaServlet #99

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
sra-013 opened this issue Aug 31, 2018 · 9 comments
Closed

GraphQLJavaServlet #99

sra-013 opened this issue Aug 31, 2018 · 9 comments
Labels

Comments

@sra-013
Copy link

sra-013 commented Aug 31, 2018

What is the replacement for SimpleGraphQLServlet (along with the required parameters to the constructor) in the latest release?

@alamothe
Copy link

alamothe commented Sep 4, 2018

I see SimpleGraphQLHttpServlet but the constructor is private again, which makes it useless inside a servlet container.

@oliemansm
Copy link
Member

You have to use the builder now to construct a SimpleGraphQLHttpServlet, e.g.:

private SimpleGraphQLHttpServlet createServlet(GraphQLSchema schema) {
  GraphQLSchemaProvider schemaProvider = new DefaultGraphQLSchemaProvider(schema);
  GraphQLInvocationInputFactory invocationInputFactory = GraphQLInvocationInputFactory.newBuilder(schemaProvider).build();
  return SimpleGraphQLHttpServlet.newBuilder(invocationInputFactory).build();
}

@alamothe To be able to use it in a servlet container you probably need #60 which is yet to be implemented.

@sra-013
Copy link
Author

sra-013 commented Sep 4, 2018

Thanks!
I resolved it by overriding the init() method of HttpServlet. :)

@alamothe
Copy link

alamothe commented Sep 4, 2018

@oliemansm It only needs constructor to be protected (it was in 5.0.1)

I don't understand why this is such a huge issue.

I'm sticking with 5.0.1 for now

@oliemansm
Copy link
Member

@alamothe Who's saying it's a huge issue? Made it protected again.

@alamothe
Copy link

alamothe commented Sep 5, 2018

@oliemansm My apologies, I wrongly assumed it was made private again on purpose and there's a reason to keep it that way.

Thanks for doing this!

@oliemansm
Copy link
Member

Sure, no problem. Not sure if this one will be part of 5.0.3 or the release after that. Depends on if the 5.0.3 release was already in the pipeline at Sonatype.

@MarkNenadov
Copy link

MarkNenadov commented Oct 3, 2018

@oliemansm is there I way you can do things like append a cookie to the response or create a custom error handling strategy with this createServlet method example you showed? That's what I'm struggling with. I used to extend SimpleGraphQLServlet's methods like createContext and getGraphQLErrorHandler, but now its not clear to me how that works with a GraphQLInvocationInputFactory. The documentation here on github is out of date (it still refers to SimpleGraphQLServlet).

@khteh
Copy link

khteh commented Jun 11, 2020

The .build() method is indicated as @deprecated in the IDE. What's the change? How to instantiate it?

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

5 participants