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

Support for GraphQL with Open Liberty 20.0.0.6

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

June 17, 2020
yasmin-aumeeruddy
Related topics:
DevOpsJavaKubernetesMicroservices
Related products:
Developer Toolset

    The Open Liberty 20.0.0.6 release brings new features, updates, and bug fixes. This article introduces the new features in Open Liberty 20.0.0.6, including support for developing "code-first" GraphQL applications, provisioning features from a Maven repository, and using a server configuration to control application startup.

    What's new in Open Liberty 20.0.0.6

    Open Liberty 20.0.0.6 includes the following feature updates, which I discuss in the next sections:

    • Using GraphQL with Open Liberty
    • Provisioning features from a Maven repository
    • Administrators control the application start order
    • New REST visualizations in Open Liberty Grafana dashboards
    • Web application startup changes

    Note: Visit Open Liberty's GitHub repository to learn about bug fixes in Open Liberty 20.0.0.6.

    Run your apps using Open Liberty 20.0.0.6

    Use the following command to get or update to Open Liberty 20.0.0.6 using Maven:

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

    If you're using Gradle, simply enter:

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

    Here's the command for Docker:

    FROM open-liberty
    

    See the Open Liberty downloads page to get the latest release for Jakarta EE 8, Web Profile 8, and MicroProfile 3.

    Using GraphQL with Open Liberty

    Open Liberty's support for MicroProfile GraphQL lets developers write "code-first" GraphQL applications that put clients in control of the data they receive. You can use annotations like @Query and @Mutation to turn Plain Old Java Objects (POJOs) into HTTP-based GraphQL endpoints. When the query or mutation method returns an existing entity object, the client can specify the fields it is interested in—which reduces network bandwidth and client-side processing.

    Here’s an example:

    @GraphQLApi
    public class MovieService {
        AtomicInteger nextId = new AtomicInteger();
        Map<Integer, Movie> movieDB = new HashMap();
    
        @Query("movieById")
        public Movie getMovieByID(int id) throws UnknownMovieException {
            return Optional.ofNullable(movieDB.get(id)).orElseThrow(UnknownMovieException::new);
        }
    
        @Query("allMoviesDirectedBy")
        public List<Movie> getAllMoviesWithDirector(String directorName) {
            return movieDB.values().stream()
                                   .filter(m -> m.getDirector().equals(directorName))
                                   .collect(Collectors.toList());
        }
    
        @Mutation("newMovie")
        public int createNewMovie(@Name("movie") Movie movie) {
            int id = nextId.incrementAndGet();
            movie.setId(id);
            movieDB.put(id, movie);
            return id;
        }
    }
    

    This code creates a GraphQL application with two queries (movieById and allMoviesDirectedBy) and a mutation (newMovie). If the client executes the following query:

    query {
      allMoviesDirectedBy(directorName: "Roland Emmerich") {
        id, title, actors
      }
    }
    

    The result will be:

    {
      "data": {
        "allMoviesDirectedBy": [
          {
            "id": 1,
            "title": "Independence Day",
            "actors": [
              "Will Smith",
              "Bill Pullman",
              "Jeff Goldblum",
              ...
            ]
          },
          ...
        ]
      }
    }
    

    Open Liberty’s GraphQL APIs were developed within the MicroProfile community and have broad industry support. The implementation is based on SmallRye GraphQL. Liberty’s GraphQL feature goes beyond the MicroProfile specification and adds support for collecting metrics, checking authorizations, and logging requests and responses to query and mutation methods.

    For more details and a sample application, see this simple demo of the MicroProfile GraphQL capabilities in Open Liberty. Join the growing landscape of GraphQL adopters and write your first GraphQL application today!

    Provisioning features from a Maven repository

    Developers can now use a convenient command-line tool to install features from the Maven Central repository or an on-premises Maven repository (such as one served on Artifactory or Nexus) directly onto an Open Liberty runtime. Table 1 details using the wlp/bin/featureUtility commands to find, install, and get information about assets in a Maven repository.

    Table 1. Open Liberty commands to install features from a Maven repository

    Command Description
    featureUtility help installFeature Display help information for the installFeature action.
    featureUtility installFeature mpHealth-2.2 or featureUtility installFeature io.openliberty.features:mpHealth-2.2 Install the MicroProfile Health 2.2 feature from Maven Central.
    featureUtility installServerFeatures myserver Install server features for the myserver server.
    featureUtility installFeature mpHealth-2.2 --noCache Install the MicroProfile Health 2.2 feature without caching the feature to the local Maven repository.
    featureUtility installServerFeatures myserver --noCache Install server features for the myserver server without caching the features to the local Maven repository.
    featureUtility installFeature adminCenter-1.0 --acceptLicense Install the Admin Center feature from Maven Central.
    featureUtility installServerFeatures defaultServer --verbose Install features for the myserver server with debugging enabled.
    featureUtility viewSettings View a template of your featureUtility.properties file.
    featureUtility find mpHealth-2.2 Search for the MicroProfile Health 2.2 feature from Maven Central and all configured Maven repositories.
    featureUtility find Search for all available features from Maven Central and all configured Maven repositories.

    Administrators control the application start order

    By default, applications start in parallel and can finish starting in random order. With the 20.0.0.6 release, Open Liberty empowers administrators to prevent an application from starting until one or more other applications have started.

    Being able to define the order of application startup is critical because applications are often dependent on each other. For example, a single Open Liberty server might contain a front-end application that provides a user interface and a back-end application that accesses a database. Having the front-end application available before the back end started could result in errors. With this feature, you could prevent the front-end application from starting until the back end was ready.

    You only need to define the application dependencies in the configuration, using the startAfter attribute on the application element. In this example, you would add a comma-separated list of ID values for the back-end applications that must start before the front-end application can run:

     <webApplication id="frontend" location="myFrontend.war" startAfter="backend1, backend2"/>
     <enterpriseApplication id="backend1" location="myBackend.ear"/>
     <enterpriseApplication id="backend2" location="myUtilities.ear"/>
    

    REST visualizations in Open Liberty Grafana dashboards

    Grafana dashboards provide a wide range of time-series visualizations of MicroProfile Metrics data such as CPU, REST, servlet, connection pool, and garbage collection metrics. Grafana dashboards are powered by a Prometheus data source, which is configured to ingest data from the /metrics endpoint of one or more Open Liberty servers. As a result, users can view the metrics on Grafana dashboards in near real-time.

    With the release of mpMetrics-2.3 and its addition of JAX-RS metrics, we've introduced a new set of visualizations to our Open Liberty Grafana dashboards. You can find these under a new tab labeled REST. We've also added hover-over descriptions that provide a brief summary of each visualization and its function. These updates apply to OKD 3.11 (the upstream distribution of Red Hat OpenShift), Red Hat OpenShift Container Platform (OCP), and standalone Open Liberty instances.

    If you do not already have Grafana and Prometheus set up in your development environment, see the Kabanero guide for Red Hat OpenShift Container Platform 4.3. To get started using the Grafana dashboard with Open Liberty, see my blog post introducing Open Liberty's support for MicroProfile 3.3.

    Note: You can find the Grafana dashboards for Open Liberty on OKD or OCP in the open-liberty-operator repository.

    Web application startup changes

    Starting with Open Liberty 20.0.0.6, web applications are considered started only after calls to ServletContainerInitializers and ServletContextListeners have completed. This update effectively moves more of the application initialization process into the server-startup route. As a result, it might appear that applications and the server take longer to start. The change doesn't affect how long it takes for applications to begin processing requests; it just moves it to run prior to the opening of the ports. In addition, you can now configure the server.xml so that a failure in a ServletContextListener will cause application startup to fail. Just add the following:

    <webContainer stopAppStartUponListenerException="true"/>
    

    Note: Find out more about application properties here.

    Conclusion

    Open Liberty 20.0.0.6 is available through Maven, Gradle, Docker, and as a downloadable archive. Get it today to begin using the new features I've described in this article.

    Last updated: February 13, 2024

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    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.