Basic differences between three GraphQL-servers.
Tags: graphql, javascript, node, vsc
Published: 2019-11-17 01:07:17

---
title: Basic differences between three GraphQL-servers.
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/fm4q0bmv2exmn054qpxd.jpeg
description: Getting the differences between the three tools in order to know when and how to use eachone.
tags: graphql, javascript, nodejs, vsc
---
Hello!!!

**TL;DR**: A comparison between express-graphql, apollo and yoga was made for a *Hello World!* Query. In order to setup a simple GraphQL API, considering the size and number of files, Express-graphql is the champion here🥇. The complexity of the SDL Implementation is not very different and definitely a more extensive analysis has to be done in order to choose a tool for an enterprise size application.


I wanted to compare express-graphql, apollo and graphql-yoga with **Node.js** The main information that I want to get are dependencies, size of development project and the most important, the way to implement the *Schema definition language* (**SDL**), in order to build the schema.



## Express-graphql.

This is the simplest way to run a GraphQL API.

#### Dependencies:

 * graphql
 * express
 * express-graphql

#### Size:

 * 5.1 MB
 * 862 files.

#### SDL implementation.

The `buildSchema` method is imported from `graphql` in order to build the schema.

```javascript
const { buildSchema } = require('graphql');

const schema = buildSchema(`
  type Query {
    hello: String!
  }
`);
```

Here is the video of all the steps.

<a href="http://www.youtube.com/watch?feature=player_embedded&v=qy2rs3aKV8w" target="_blank"><img src="http://img.youtube.com/vi/qy2rs3aKV8w/0.jpg" alt="Video preview"/></a>

## Apollo Server.

At the [Apollo Documentation](https://www.apollographql.com/docs/apollo-server/) we can read that Apollo Server is the best way to build a production-ready, self-documenting API for GraphQL API clients, using data from any source.

#### Dependencies:

 * graphql
 * apollo-server

#### Size:

 * 16.7 MB
 * 4,502 files.

#### SDL Implementation

 * The `gql` function is imported from `apollo-server` to parse the plain string that contains the GraphQL code.

```javascript
const { gql } = require('apollo-server');

const typeDefs = qgl`
  type Query {
    hello: String!
  }
`;
```

Is worth to note a difference between the resolvers with Express and Apollo, in the former you only add the function which will resolve the `hello` Query. In the last, you have to define the resolvers according to the types. 

Also I made a video implementing the Apollo server.

<a href="http://www.youtube.com/watch?feature=player_embedded&v=JftEqTGhkjU" target="_blank"><img src="http://img.youtube.com/vi/JftEqTGhkjU/0.jpg" alt="Video preview"/></a>

## GraphQL-Yoga Server

Graphql-yoga is a fully-featured GraphQL Server focused on easy setup, performance and great developer experience as can be read at the [creator's repo](https://github.com/prisma-labs/graphql-yoga). It was created by Prisma.

#### Dependencies:

 * graphql-yoga

#### Size:

 * 14.6 MB
 * 4,634 files.

#### SDL Implementation

 * In this case, any function has to be imported in order to parse the plain string, so the schema is created out of it completely.

```javascript

const typeDefs = `
  type Query {
    hello(name: String): String!
  }
`;
```

The resolvers have to be defined in the same way as with Apollo, by type and field.

Here is the video of the same API that have been created in the other two cases. In this example, the query can take an String argument.

<a href="http://www.youtube.com/watch?feature=player_embedded&v=B1pAzfPudQA" target="_blank"><img src="http://img.youtube.com/vi/B1pAzfPudQA/0.jpg" alt="Video preview"/></a>