.../articles/
Trying GraphQL Playground Desktop

Trying GraphQL Playground Desktop

2019.11.19

Installation

You can download it from GitHub or install it via brew cask — whichever method you prefer.

GitHub https://github.com/prisma-labs/graphql-playground/releases

# brew cask install command
brew cask install graphql-playground

Choosing an endpoint

When it launches, you'll see an endpoint selection screen. This time, let's connect to Pokemon under EXAMPLES.

I found a list of GraphQL servers you can try out right away, like this Pokemon server, so I'll share it here.

Public GraphQL APIs http://apis.guru/graphql-apis/

Checking the schema and running a query

Click SCHEMA on the right side to check the GraphQL schema.

type Attack {
  name: String
  type: String
  damage: Int
}

type Pokemon {
  id: ID!
  number: String
  name: String
  weight: PokemonDimension
  height: PokemonDimension
  classification: String
  types: [String]
  resistant: [String]
  attacks: PokemonAttack
  weaknesses: [String]
  fleeRate: Float
  maxCP: Int
  evolutions: [Pokemon]
  evolutionRequirements: PokemonEvolutionRequirement
  maxHP: Int
  image: String
}

type PokemonAttack {
  fast: [Attack]
  special: [Attack]
}

type PokemonDimension {
  minimum: String
  maximum: String
}

type PokemonEvolutionRequirement {
  amount: Int
  name: String
}

type Query {
  query: Query
  pokemons(first: Int!): [Pokemon]
  pokemon(id: String, name: String): Pokemon
}

Looking at the schema, we can see two queries: pokemon and pokemons. This time, let's call the pokemon query. The pokemon query requires either an id or a name argument, and since id doesn't hold a value related to the actual Pokemon, we'll specify Growlithe for name.

query{
  # Specify "Growlithe" as the argument
  pokemon(name:"Growlithe"){
    # List the fields we want
    id
    name
    image
    # For nested fields too, check the return type and list the fields we want
    attacks{
      fast{
        name
        type
        damage
      }
      special{
        name
        type
        damage
      }
    }
    evolutions{
      id
      name
      image
    }
  }
}

If it processes successfully, you'll get data back like this:

{
  "data": {
    "pokemon": {
      "id": "UG9rZW1vbjowNTg=",
      "name": "Growlithe",
      "image": "https://img.pokemondb.net/artwork/growlithe.jpg",
      "attacks": {
        "fast": [
          {
            "name": "Bite",
            "type": "Dark",
            "damage": 6
          },
          {
            "name": "Ember",
            "type": "Fire",
            "damage": 10
          }
        ],
        "special": [
          {
            "name": "Body Slam",
            "type": "Normal",
            "damage": 40
          },
          {
            "name": "Flame Wheel",
            "type": "Fire",
            "damage": 40
          },
          {
            "name": "Flamethrower",
            "type": "Fire",
            "damage": 55
          }
        ]
      },
      "evolutions": [
        {
          "id": "UG9rZW1vbjowNTk=",
          "name": "Arcanine",
          "image": "https://img.pokemondb.net/artwork/arcanine.jpg"
        }
      ]
    }
  }
}

Our own qrop project uses GraphQL, and by the time I joined the project, there was already a wonderful setup where running docker-compose up would spin up a Playground on localhost. Still, I found that trying out this minimal setup helped me understand the basics more clearly. That's it for this post.

written by

.../article/

Articles

All articles

From Firebase to Vercel, Contentful to microCMS — a migration log written with Claude Code

From Firebase to Vercel, Contentful to microCMS — a migration log written with Claude Code

We moved our corporate site's hosting and CMS, and made it bilingual along the way. The constraints we only found by running against real data were more useful than the migration itself, so this post focuses on where we got stuck.

Can't Read POST Data with Firebase Functions × Remix?

Can't Read POST Data with Firebase Functions × Remix?

How to read POST data from a Remix action when running on Firebase Functions.

Generative AI for Executives and Leaders: An Approach to Self-Driven DX

Generative AI for Executives and Leaders: An Approach to Self-Driven DX

Building a structure where executives and leaders themselves can identify issues and evaluate solutions using generative AI. We introduce how combining this with our hands-on support dramatically improves both the quality and speed of digital transformation.

Deploying a Monorepo Next.js App (App Router) to AWS Amplify

Deploying a Monorepo Next.js App (App Router) to AWS Amplify

Notes on the obstacles we hit while deploying a Next.js app managed in a monorepo to AWS Amplify.

Keeping Production Running Smoothly with Remote Work and Online Meetings [Documentation]

Keeping Production Running Smoothly with Remote Work and Online Meetings [Documentation]

Many production companies have adopted remote work as a result of the pandemic, and we are one of them.

Designing an E-Commerce Site That Sells: How to Find Great Reference Examples

Designing an E-Commerce Site That Sells: How to Find Great Reference Examples

There is no single formula for e-commerce design that sells. Driving revenue requires a solid concept, and getting to that concept requires thorough research.

Productivity Tools We Recommend as a Production Company, Including Services That Work Well Solo

Productivity Tools We Recommend as a Production Company, Including Services That Work Well Solo

With remote work becoming the norm during the COVID-19 pandemic, our team now works from home most days of the week.

We Released Thought Recorder, a Figma Plugin for Keeping a Commit History of Your Designs

We Released Thought Recorder, a Figma Plugin for Keeping a Commit History of Your Designs

We hope this helps web designers who work in Figma. Read on for how to use it.

How to Build an E-Commerce Site, and Which Platforms We Recommend

How to Build an E-Commerce Site, and Which Platforms We Recommend

Shopping online for fashion, appliances, and even groceries is now routine. With the pandemic accelerating the shift, we receive a steady stream of questions about which platform to use and how much it costs.

Generating FastAPI Schema Classes from OpenAPI

Generating FastAPI Schema Classes from OpenAPI

We chose FastAPI, a relatively modern framework, for a Python API project. FastAPI can generate an OpenAPI definition from your backend code, but here we do the opposite: generating FastAPI schema classes from an OpenAPI definition prepared in advance.

View all articles

Contact us