Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
681 views
in Technique[技术] by (71.8m points)

rest - how to use GraphQL from Java?

Any webservice which supports GraphQL is consumable through a Java implementation? Because "it provides an alternative to REST..."?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Graphql-java (that you linked to) is an implementation of the GraphQL specification. As such, it is used to create GraphQL servers. A client doesn't need anything special to consume a service, just like it doesn't need anything special to consume a REST service - only to be be able to speak HTTP. You can use any generic HTTP client you like.

Still, you have some more convenient options for creating clients (but both somewhat lacking):

  1. Apollo Android - Don't let the name fool you, it's perfectly usable from normal Java. Not the most ergonomic solution, but it works.
  2. Shopify's Graphql Java Generator - Unfortunately, requires Ruby to build (not to run, of course). Generates Java classes for creating queries in a type-safe way, similar to what wsdl2java Maven plugin does for SOAP services.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...