Skip to content

Compare different implementations of GraphQL on the server side. A bit like TodoMVC, but with a different example, showing features of GraphQL and how to implement them in various languages and frameworks.

License

Notifications You must be signed in to change notification settings

Adeynack/graphql_examples

Repository files navigation

graphql_examples

Compare different implementations of GraphQL on the server side. A bit like TodoMVC, but with a different example, showing features of GraphQL and how to implement them in various languages and frameworks.

Where to find implementations?

In the examples folder of this repository, named by convention language_framework_library (examples: rails, ts_apollo).

Application to build

A minimalist post system, à la Facebook, with users, posts, comments and a possibility to like the posts.

Data Model

Data model

A post

  • belongs to a user
  • has many likes
  • may belong to a parent post, if its a comment

A like

  • belongs to a post
  • belongs to a user

A user

  • has many posts
  • has many likes

GraphQL Schema

Query Object

GraphQL Query Object

Mutations

See mutations.

Goals

Avoid N+1 Queries to the Database

Use batch loading when available to the language and framework of choice.

Tests

An implementation agnostic test suite, in JavaScript, is in tests.

See tests/README.md.

Development

Generate PlantUML Diagrams as Images

At this moment, generating them using the PlantUML plugin of VSCode, calling the PlantUML: Export Workspace Diagrams command, and choosing svg.

Service Dependencies and Development Container

This workspace is set up for Visual Studio Code and includes a devcontainer.

Upon opening it up in Visual Studio Code, click Open in container in the bottom-right popup that appears. The required services (eg: PostgreSQL) and the development environment itself will build (only once) and then you're all set to work on this project, without installing anything else than Docker and Visual Studio Code on your computer.

Don't want to use vscode?

It is absolutely possible to use the devcontainer without using Visual Studio Code. Execute the following command from the root of the workspace, and

docker compose -f .devcontainer/docker-compose.yml up
# in another terminal tab/window
bin/attach_docker

Ideas for the future

  • Connections/Nodes/Edges
    • Arrays can be paginated
  • Relay-Style Object Identification
    • Objects export their GID
    • Objects are obtainable from their GID

About

Compare different implementations of GraphQL on the server side. A bit like TodoMVC, but with a different example, showing features of GraphQL and how to implement them in various languages and frameworks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published