GraphQL is a remote data access API that addresses issues like under-fetching and over-fetching that are inherent in most RESTful applications. It allows clients to specify the exact data they want - to “have it their way”. If you would like to learn more about GraphQL, I recommend checking out the tutorial at GraphQL.org.
GraphQL applications use a schema that acts as a description of the data provided by the server and as a contract between the client and server. Most GraphQL programming models require developers to dual-maintain their schema and the application code that supports it. MicroProfile GraphQL takes a “code first” approach which allows developers to write Java code using annotations to mark GraphQL schema elements, and then the MicroProfile GraphQL implementation generates the schema at runtime.
In this blog post, we’ll explore how easy it is to create GraphQL applications using this sample.
Setup
To set up your Maven environment for developing a MP GraphQL application, you’ll need a dependency like:
XML

org.eclipse.microprofile.graphql
microprofile-graphql-api
1.0.2
provided

I recommend using the Liberty Maven plugin, but it’s not strictly necessary so long as you generate a Web Archive (WAR) file for deployment.
When configuring the Liberty server for deployment, make sure that the featureManager element in the server.xml file contains the mpGraphQL-1.0 feature. For example:
XML


mpGraphQL-1.0
mpMetrics-2.3

The mpMetrics-2.3 feature is not required, but will track the number of GraphQL query/mutation invocations and cumulative time when enabled. Now that we've got things set up, let's look at the code.

#tutorial #integration #graphql #microprofile #graphql applications

Have It Your Way With MicroProfile GraphQL - DZone Web Dev
1.70 GEEK