Application 2023-11-09

What is GraphQL? A Complete Guide with Practical Examples

Summarizing what I researched while practicing GraphQL.

Read in: ja
What is GraphQL? A Complete Guide with Practical Examples

Overview

I have been practicing GraphQL, so I am summarizing what I researched.

There is a helpful tutorial available, making it easy to get started. cf. www.howtographql.com

What is GraphQL

A query language for Web API development developed by Meta.

GraphQL is managed by the GraphQL Foundation, of which Meta is a member.

The specifications of GraphQL and all related projects are open source.

Features

Terminology

Only a few selected terms are listed.

Schema

Type definitions for queries.

type Query {
  user: User
}

Query

A query for data retrieval.

query {
  user {
	name
  }
}

Mutation

A query for data updates.

mutation {
  updateUser {
	name
  }
}

Subscription

A query to monitor data changes.

subscription {
  user {
	name
  }
}

Argument

Arguments passed to a query.

{
  user(id: 123) {
    username
    email
  }
}

Related Technologies

GraphQL Mesh

A gateway server (GraphQL Gateway) for APIs implemented with specifications like gRPC, OpenAPI, Swagger, oData, SOAP, GraphQL, etc.

As long as there is an API specification, you can access the API with GraphQL queries.

cf. the-guild.dev

openapi-to-graphql

Converts API specifications based on OpenAPI to GraphQL Schema.

cf. github.com - IBM/openapi-to-graphql

graphql-tools

A handy tool for creating GraphQL Schemas. Can also create mocks.

cf. github.com - ardatan/graphql-tools

GraphQL Gateway

Performance

Impressions

Compared to Restful APIs, it might take a bit more effort to get started, but the benefits seem significant.

There seem to be various types of GraphQL clients, which might make selection challenging.

cf. user-first.ikyu.co.jp - Apollo Client May Not Be Necessary for Your Product

References

Tags: GraphQL
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles