Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Quicker, easier GraphQL queries with Open Liberty 20.0.0.9

September 29, 2020
Jakub Pomykala
Related topics:
JavaMicroservicesKubernetesOpen source

    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

    • Red Hat Enterprise Linux 10.2 and 9.8: Top features for developers

    • What GPU kernels mean for your distributed inference

    • Debugging image mode with Red Hat OpenShift 4.20: A practical guide

    • EvalHub: Because "looks good to me" isn't a benchmark

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.