Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
 
 
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Symfony GraphQL API

This module is to be used to create a list of locations by users - we can assume, that it is about Events that will take place at the address indicated and will last at the specified address time interval (date from - to). The module returns a list of added events, and the user can find any by entering the name of the event in the search engine.

env options (.env.local)

APP_ENV
DATABASE_URL
DEV_CLIENT_API_TOKEN
API_ITEMS_PER_PAGE

Install

composer install
php bin/console doctrine:database:create
php bin/console doctrine:schema:update --force
php bin/console doctrine:fixtures:load --append --group=users

Create API user

php bin/console app:create-api-user username api_key

Show API Token

php bin/console app:show-api-user-token username

Start server

sh start_server.sh

Tests

php ./vendor/bin/phpunit

Queries

Events List:

query {
  events_list(limit:100, page:1) {
    events {
      id
      name
      slug
      email
      streetAddress
      city
      country
      zipcode
      dateFrom
      dateTo
    }
  }
}

Single Event:

query {
  event(id:"bca2bbaf-f44e-4e06-a6cb-4922ccf245da") {
    id
    name
    slug
    email
    streetAddress
    city
    country
    zipcode
    dateFrom
    dateTo
  }
}

Events Search:

query {
  events_search(phrase:"Impreza") {
    events {
      id
      name
      slug
      email
      streetAddress
      city
      country
      zipcode
      dateFrom
      dateTo
    }
  }
}

Mutations

Create Event

mutation {
  event_create(input: {
    name: "Jakieś wydarzenie"
    streetAddress: "al. Warszawska 12"
    country: "PL"
    city: "Olsztyn"
    zipcode: "10-082"
    email: "jan@kowalski.dev"
    dateFrom: "2020-01-01"
    dateTo: "2020-02-25"
  }) {
    id
  }
}

Client for dev

After start server open http://localhost:3000/graphiql.

GraphiQL.png

Elasticsearch

Check Elasticsearch status. Should be active.

sudo systemctl status elasticsearch

Check Elasticsearch version:

curl http://localhost:9200

Required 7.* for this project.

Create indexes

You need to create the indexes in Elasticsearch. This can be easily done running the following command:

php bin/console fos:elastica:create

Populate data

You can populate the information of the table in Elasticsearch running the following command:

php bin/console fos:elastica:populate

Bibliography

Copyrights

Copyright (c) Rafał Mikołajun 2021.

About

Sample GraphQL API written in Symfony.

Topics

Resources

Releases

No releases published

Packages

No packages published