Crea un Chat con GraphQL y React

- GraphQL part -

Cesar Guerrero

Front End Developer

@mono_guerin

Requirements

  • Node.js  v10+
  • Text Editor VsCode is preferred
  • Javascript basic knowledge
  • Postman
  • Heroku account
  • Github account
  • Basic Git knowledge

Agenda

  • What is GraphQL?
  • Express web server
  • REST endpoints
  • GraphQL server
  • Query and Mutations
  • Suscriptions
  • Demo

What is GraphQL?

  • GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data

Express

  • Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

Let's create our web server

Create a new folder for the project, name it "chat-server"

mkdir chat-server && cd chat-server

Init project with npm using the next code

npm init -y

Install express dependency

npm install express

Create a new folder called src and a file called index.js and create the hello world example from express

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(3000, () => {
  console.log('Example app listening on port 3000!');
});

Let's add a linter to the project!

Install eslint dependency

npm install --save-dev eslint

Run init command and follow instructions

npx eslint --init

Make any necessary changes!

Made with Slides.com