GraphQL

main principle - code on the browser forms a query describing the data wanted and sends it to the API with a HTTP POST request -- all queries are sent to same address.

GraphQL schema

  • contract between the server and client
  • abstraction layer that provides flexibily to consumers and hide back-end implementation
  • defines what API can and can't do; how clients can request or change data
  • collection of object types containing fields
  • schema describes two types:
    1. object type containing scalar types - leaves of the graph (concrete data)
    2. query type - tells what kind of queries can be made to API - direct link between query and returned JSON object

Apollo server

Apollo Client

Apollo client is a state management library to use GraphQL to interact with remote server. Client enables you to manage local state alongside remotely fetched state. A single API to interact with all of the application's state. 1

[React] hooks: