GraphQL Server and GraphQL Client

A brief introduction to the GraphQL server and client.

Now that we have an idea of what GraphQL is, let’s delve deeper into its implementation.

GraphQL’s implementation can be divided into two components:

  1. Server Component
  2. Client Component

GraphQL Server

A GraphQL server essentially takes in your API and exposes your GraphQL API via an endpoint. It has two core parts:

  • A Schema
  • Resolve functions

Schema

The schema is a model of the data that can be retrieved through the GraphQL server. It specifies what queries clients are allowed to make, what types (scalar, object, query, mutation) of data can be fetched from the server, and what the relationships between these types are.

That being said, there is one critical piece of information that the schema doesn’t provide: where the data for each type comes from.

This is where resolve functions come in.

Resolve Functions

Resolve functions are like little routers. They specify how the types and fields in the schema are connected to various backends. Through these functions, you are able to answer questions such as “How do I get the data regarding Course Authors?” and “Which backend do I need to call with what arguments to get the data regarding Courses?”.

Perhaps the greatest feature of GraphQL is that it hides all of the backend complexity from the clients. Even if your app uses multiple backends, all the client will see is a single GraphQL endpoint with a simple, self-documenting API for your application.

GraphQL Client

A GraphQL client is the front end component where you are actually able to accept queries, connect to the GraphQL endpoint, and make queries to collect data. The GraphQL client is straightforward and will be our main focus throughout this course.

Get hands-on with 1200+ tech skills courses.