Skip to content

macaw-cad/hello-graphql

Repository files navigation

Changes from Mirella

GraphQL PoC

This PoC was created in order to figure out GraphQL combined with Apollo.

! Before running the app !

Make sure you add an .env file at the root of the project with a "themoviedb.org" API key in this format: API=xxxxxxx.

Team developers can find a shared key here.

Converting GraphQL TypeDefs to Typescript

  1. Run the server using npm run server. (the schema.json generator uses this server)
  2. Run the command to generate the schema.json and the Typescript file: npm run generate-types

GraphQL

GraphQL is only a specification

Tutorial

The best tutorial out there to get started (link)

Concepts

  • Schema
    • Collection of GraphQL types
    • Contract between client and server
  • Mutations (Create, update, delete data) (link)
  • Subscriptions (Real time updates)
  • Resolver functions (??)

Clients

2 major GraphQL clients

Comparison:

Relay Modern:

  • Very opinionated structure and naming convention (src)
  • Takes a little more development time (src)
  • Works well with React Native (src)

Apollo:

  • Has an ecosystem around it (src)
  • Built on top of Redux (src)

Why GraphQL client?

No need to worry about low-level networking tasks (fetch functions), all you need to do with GraphQL is write a query where you declare your data requirements.

GraphQL + React

GraphQL clients use the concept of higher-order components to fetch the needed data under the hood and make it available in the props of your components.

Server

Links