Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Quicker, easier GraphQL queries with Open Liberty 20.0.0.9

September 29, 2020
Jakub Pomykala
Related topics:
JavaMicroservicesKubernetesOpen source

Share:

    Open Liberty 20.0.0.9 lets developers experiment with the type-safe SmallRye GraphQL Client API, and write and run GraphQL queries and mutations more easily with a built-in GraphiQL user interface (UI). This article introduces the new features and updates in Open Liberty 20.0.0.9:

    • Experiment with a third-party GraphQL client API.
    • Use the built-in GraphiQL UI for faster queries and mutations.
    • Give us your feedback!

    Run your apps using Open Liberty 20.0.0.9

    If you are using Maven, use these coordinates to update to the newest version of Open Liberty:

    <dependency>
        <groupId>io.openliberty</groupId>
        <artifactId>openliberty-runtime</artifactId>
        <version>20.0.0.9</version>
        <type>zip</type>
    </dependency>
    

    For Gradle, enter:

    dependencies {
        libertyRuntime group: 'io.openliberty', name: 'openliberty-runtime', version: '[20.0.0.9,)'
    }
    

    If you're using Docker, it's:

    FROM open-liberty
    

    Experiment with a third-party GraphQL client API

    MicroProfile GraphQL has only been available in Open Liberty for a few months, and it is already a hit. That said, there are a few ways that we want to improve it and make it more complete. One feature that we want to improve is the GraphQL client API. While the official client API is not expected until the next release of MicroProfile GraphQL, you can start experimenting now with the type-safe SmallRye GraphQL client API.

    SmallRye is the underlying implementation of MicroProfile GraphQL. You can access its above-and-beyond-the-spec features by adding the "third-party" API type visibility to your application:

    <application name="MyGraphQLApp" location="MyGraphQLApp.war">
        <classloader apiTypeVisibility="+third-party"/>
    </application>
    

    This update lets you access SmallRye GraphQL APIs like the type-safe client. Note that these APIs might change in future releases because SmallRye is continuously evolving. For more information, please visit SmallRye GraphQL project. For Open Liberty 20.0.0.9, we are using SmallRye GraphQL 1.0.7.

    Type-safe invocation for remote methods

    The SmallRye GraphQL client APIs are very similar to MicroProfile Rest Client, which uses an interface to invoke remote methods in a type-safe manner. For example, suppose we want a client that can invoke a query of all of the superheroes in a given location. We would create a query interface like this:

    @GraphQlClientApi
    interface SuperHeroesApi {
        List allHeroesIn(String location);
    }
    

    Where SuperHero on the client-side looks like this:

    class SuperHero {
        private String name;
        private List superPowers;
    }
    

    The SuperHero entity might contain dozens of fields on the server-side, but if we're only interested in the hero's name and superpowers, then we only need those two fields in our client-side class. Now, we can invoke the query with code like this:

    SuperHeroesApi api = GraphQlClientBuilder.newBuilder().build(SuperHeroesApi.class);
    List heroesOfNewYork = api.allHeroesIn("NYC");
    

    Remember that this client API is not official, but the official MicroProfile GraphQL 1.1 API will be based on it. Think of this as a preview.

    Use the built-in GraphiQL UI for faster queries and mutations

    Open Liberty now sports a built-in GraphiQL user interface as shown in Figure 1. The new, web-based UI allows you to write and execute GraphQL queries and mutations in real-time with advanced editing features like command completion, query history, schema introspection, and so on.

    Web UI open to edit a query, with hover-over text displayed.
    Figure 1: Work faster with the GraphiQL web UI.

    To enable the UI, you must first write and deploy a MicroProfile GraphQL application. Then add this line to your server.xml:

    <variable name="io.openliberty.enableGraphQLUI" value="true" />
    

    You can use a web browser to access the UI, by merely opening your GraphQL application's context root and adding /graphql-ui. As an example, suppose that we use the default port (9080) and our application is namedmyGraphQLApp. In that case, we would access the UI at http://localhost:9080/myGraphQLApp/graphql-ui.

    This workaround was resolved in issue #13201.

    We want your feedback

    As an open source team, we love receiving feedback from Open Liberty users. A recent example is this comment, taken from Open Liberty #13036): "Hello, I am using microprofile-graphql on openliberty and everything goes well except for the exception whitelisting mechanism via microprofile config ..."

    Our MicroProfile GraphQL feature has only been generally available for a few months, so it's great to know that users are adopting it. We're also excited that some of you are already exploring the "dark corners" of exception handling and similar features.

    While we dislike discovering that we let a bug slip through the cracks, we're eager to fix them when they do. If you find an issue or want to suggest an enhancement that would make your experience with Open Liberty better, please let us know. You can always reach us by opening an issue on GitHub or contacting us on Twitter at @OpenLibertyIO. We're also available to chat online using Gitter and on the Open Liberty Developer Experience page.

    Try Open Liberty 20.0.0.8 in Red Hat Runtimes now

    Open Liberty is part of the Red Hat Runtimes offering and is available to Red Hat Runtimes subscribers. To learn more about deploying Open Liberty applications to Red Hat OpenShift, see our Open Liberty guide: Deploying microservices to OpenShift.

    Last updated: September 25, 2020

    Recent Posts

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    • How to debug confidential containers securely

    • Announcing self-service access to Red Hat Enterprise Linux for Business Developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue