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

Getting Started with GraphQL using GitHub API

November 13, 2017
Harshit Prasad
Related topics:
Developer tools

    GraphQL is a query language for APIs. It provides a complete and understandable description of the data in your API and gives clients the power to ask for exactly what they need and nothing more.

    Send a GraphQL query to your API and get exactly what you need. These queries always return predictable results using GraphQL. It is fast and stable.

    Once you have opened the GraphQL explorer provided by GitHub, you'll notice that it will display a sample query in the left panel that should look like this:

    # We'll get a sample query showing your username!
    query {
      viewer {
        login
      }
    }
    

    By using GraphQL, we can create useful queries, grab a query’s response, and also create mutations.

    GraphQL can be used to check database IDs. For example:

    {
        user(login: "yourUsername") {
            databaseId
        }
    }

    The response will be generated like this:

    {
        "data": {
            "user": {
                "databaseId": 12345678
            } 
        }
    }

    Next, I will explain the mutation example using GraphQL with GitHub. Suppose if someone has to add a reaction to an issue. We will be doing this by using GraphQL.

    {
     repository(owner: "yourName", name: "repository-name") {
       issues(last: 5) {
         edges {
           node {
             title
             id
           }
         }
       }
     }
    }

    It will generate a response like this:

    {
     "data": {
       "repository": {
         "issues": {
           "edges": [
             {
               "node": {
                 "title": "Title of the 1st issue",
                 "id": "MDU6SRXNXzdWUyMTg2NTcwMzk="
               }
             },
             {
               "node": {
                 "title": "Another issue",
                 "id": "MDU6SRXXNzdWUyMTg2NjA4OTQ="
               }
             }
           ]
         }
       }
     }
    }

    It will automatically generate unique IDs for each different type of issue. Now, we will be using the concept of the mutation to add reaction to any one of the issues by using its unique ID.

    mutation {
     addReaction(input: {subjectId: "MDU6SRXXNzdWUyMTg2NjA4OTQ=", content: LAUGH}) {
       reaction {
         content
         id
       }
     }
    }

    Hence, this will add a "LAUGH" reaction to the issue. It can also be observed by checking the response we're getting:

    {
     "data": {
       "addReaction": {
         "reaction": {
           "content": "LAUGH",
           "id": "MDg6UmVhY3Rpb24xNTQyNTUxMQ=="
         }
       }
     }
    }

    Join the Red Hat Developer Program (it’s free) and get access to related cheat sheets, books, and product downloads.

    Last updated: November 9, 2017

    Recent Posts

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    • Preventing GPU waste: A guide to JIT checkpointing with Kubeflow Trainer on OpenShift AI

    • How to manage TLS certificates used by OpenShift GitOps operator

    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.