The project is an example of GraphQL API implementation using Symfony 5 framework and library GraphQLBundle (vendor Overblog). The project consists of four Docker containers (php, mysql, nginx, mongodb).
-
Cloning the repository:
[email protected]:Pruanik/graphql_example_project.git
-
Configuring the .env file:
cp .env_example .env
-
Building containers:
make build
-
Starting containers
make up
-
Installing dependencies:
make composer-install
-
Running the migrations and filling the fixtures:
make init
-
Let's see the result:
To build containers:
make build
To install all composer dependencies:
make composer-install
To start containers:
make up
To start application containers if you have databases locally:
up-without-databases
To run migrations and pour fixtures:
make init
For stopping containers:
make stop
To enter the main container with the application:
make enter
- By default the project starts on port 8080, so the link will be http://localhost:8080/
- Overblog/graphiql-bundle library is included into the project for easy testing of queries to GraphQL server. To use interactive mode you should follow the link: http://localhost:8080/graphiql
- To access the GraphQL server using a client (e.g. Postman), you should send requests to: http://localhost:8080/graphql/
- GraphQL data schema are stored in config/graphql/types/Domain/Input and config/graphql/types/Domain/Object for mutations and objects.
- In the migration folder, the actual migrations for starting the application.
- The src/Document and src/Entity folders describe all entities for MongoDb and Mysql.
- The src/GraphQL folder contains all custom classes for building GraphQL logic for our Symfony application.
- src/Listener/ReferencesListener.php - is needed to configure relational links between entities stored in mysql and entities in MongoDb.
- The src/Model folder contains all classes of our Symfony application.
- src/Security/ApiTokenAuthenticator.php - here we implement a custom way to authenticate a user by the presence of a key in the request header.
- GraphQL w Symfony | Mariusz Bąk | Boldare
- Павел Черторогов — Строим GraphQL-сервер
- Александр Демченко «Graphql + Symfony» | CODEiD (11.08.2018)
- Comparison of API architectural styles: SOAP vs REST vs GraphQL vs RPC
- 5 reasons why you shouldn't use GraphQL
- What is the N+1 Problem in GraphQL?
- How to set up a GraphQL server with Symfony 4?
- Setting up GraphQL with PHP: Defer field resolving