mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-25 04:40:21 +00:00
feat: add graphiql
This commit is contained in:
parent
a59b1e0ef2
commit
875f065275
6 changed files with 119 additions and 21 deletions
16
Makefile
16
Makefile
|
@ -1,8 +1,10 @@
|
|||
veekun_pokedex_repository = ../pokedex
|
||||
local_config = --settings=config.local
|
||||
docker_config = --settings=config.docker-compose
|
||||
HASURA_GRAPHQL_ADMIN_SECRET=pokemon
|
||||
|
||||
.PHONY: help
|
||||
.SILENT:
|
||||
|
||||
help:
|
||||
@grep -E '^[a-zA-Z_-]+:.*?# .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
@ -81,14 +83,20 @@ pull-veekun:
|
|||
git -C ${veekun_pokedex_repository} checkout master-pokeapi
|
||||
git -C ${veekun_pokedex_repository} pull
|
||||
|
||||
sync-from-veekun: pull pull-veekun # Copy data from ../pokedex to this repository
|
||||
sync-from-veekun: pull pull-veekun # Copy data from ../pokedex to this repository
|
||||
cp -a ${veekun_pokedex_repository}/pokedex/data/csv/. ./data/v2/csv
|
||||
|
||||
sync-to-veekun: pull pull-veekun # Copy data from this repository to ../pokedex
|
||||
sync-to-veekun: pull pull-veekun # Copy data from this repository to ../pokedex
|
||||
cp -a ./data/v2/csv/. ${veekun_pokedex_repository}/pokedex/data/csv
|
||||
|
||||
read-env-file: # Exports ./.env into shell environment variables
|
||||
export `egrep -v '^#' .env | xargs`
|
||||
|
||||
hasura-export: # Export Hasura configuration
|
||||
hasura md export --project hasura --admin-secret pokemon
|
||||
hasura md export --project hasura --admin-secret ${HASURA_GRAPHQL_ADMIN_SECRET}
|
||||
|
||||
hasura-apply: # Apply local Hasura configuration
|
||||
hasura md apply --project hasura --admin-secret pokemon
|
||||
hasura md apply --project hasura --admin-secret ${HASURA_GRAPHQL_ADMIN_SECRET}
|
||||
|
||||
hasura-get-anon-schema: # Dumps GraphQL schema
|
||||
gq http://localhost:8080/v1/graphql --introspect > hasura/schema.graphql
|
||||
|
|
31
Resources/compose/docker-compose-prod-graphql.yml
Normal file
31
Resources/compose/docker-compose-prod-graphql.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
version: '2.4'
|
||||
services:
|
||||
db:
|
||||
environment:
|
||||
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
|
||||
POSTGRES_USER: "${POSTGRES_USER}"
|
||||
|
||||
app:
|
||||
env_file: .env
|
||||
|
||||
web:
|
||||
volumes:
|
||||
- graphiql:/public-console:ro
|
||||
|
||||
graphql-engine:
|
||||
environment:
|
||||
HASURA_GRAPHQL_DATABASE_URL: "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/pokeapi"
|
||||
HASURA_GRAPHQL_ADMIN_SECRET: "${HASURA_GRAPHQL_ADMIN_SECRET}"
|
||||
|
||||
graphiql:
|
||||
image: pokeapi/graphiql:1.0.0
|
||||
command: sh -c 'cp -a /app/static/. /transfer/ && tail -f /etc/passwd'
|
||||
volumes:
|
||||
- graphiql:/transfer
|
||||
depends_on:
|
||||
- graphql-engine
|
||||
|
||||
volumes:
|
||||
graphiql:
|
||||
|
||||
# docker-compose -f docker-compose.yml -f Resources/compose/docker-compose-graphql.yml up
|
|
@ -1,2 +0,0 @@
|
|||
FROM nginx:alpine
|
||||
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
|
@ -38,6 +38,23 @@ http {
|
|||
server app:8000 fail_timeout=0;
|
||||
}
|
||||
|
||||
upstream graphql_upstream {
|
||||
server graphql-engine:8080 fail_timeout=0;
|
||||
}
|
||||
|
||||
geo $limit {
|
||||
default 1;
|
||||
10.0.0.0/8 0;
|
||||
192.168.0.0/24 0;
|
||||
}
|
||||
|
||||
map $limit $limit_key {
|
||||
0 "";
|
||||
1 $binary_remote_addr;
|
||||
}
|
||||
|
||||
limit_req_zone $limit_key zone=graphqlDefaultLimit:50m rate=1r/m;
|
||||
|
||||
server {
|
||||
listen 80 deferred;
|
||||
server_name _;
|
||||
|
@ -47,6 +64,48 @@ http {
|
|||
|
||||
root /code;
|
||||
|
||||
|
||||
# Admin console
|
||||
location /graphql/admin/ {
|
||||
expires 1m; # client-side caching, one minute for each API resource
|
||||
add_header Cache-Control "public";
|
||||
add_header Pragma public;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
proxy_redirect off;
|
||||
|
||||
proxy_pass http://graphql_upstream/;
|
||||
}
|
||||
|
||||
location /graphql/console {
|
||||
alias /public-console/;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html =405;
|
||||
}
|
||||
|
||||
location /graphql/v1beta {
|
||||
limit_req zone=graphqlDefaultLimit burst=100 nodelay;
|
||||
limit_req_status 429;
|
||||
expires 1m; # client-side caching, one minute for each API resource
|
||||
add_header Cache-Control "public";
|
||||
add_header Pragma public;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
proxy_redirect off;
|
||||
|
||||
proxy_pass http://graphql_upstream/v1/graphql;
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
root /code;
|
||||
autoindex off;
|
||||
|
@ -57,14 +116,6 @@ http {
|
|||
autoindex off;
|
||||
}
|
||||
|
||||
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { # cache all these extensions for 5 days, disable logging
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
expires 5d;
|
||||
add_header Cache-Control "public";
|
||||
add_header Pragma public;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
expires 1m; # client-side caching, one minute for each API resource
|
||||
add_header Cache-Control "public";
|
||||
|
@ -79,6 +130,14 @@ http {
|
|||
proxy_pass http://pokeapi_upstream;
|
||||
}
|
||||
|
||||
# location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { # cache all these extensions for 5 days, disable logging
|
||||
# access_log off;
|
||||
# log_not_found off;
|
||||
# expires 5d;
|
||||
# add_header Cache-Control "public";
|
||||
# add_header Pragma public;
|
||||
# }
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
# Docker settings
|
||||
import os
|
||||
from .settings import *
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
||||
"NAME": "pokeapi",
|
||||
"USER": "ash",
|
||||
"PASSWORD": "pokemon",
|
||||
"USER": os.environ.get("POSTGRES_USER", "ash"),
|
||||
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", "pokemon"),
|
||||
"HOST": "db",
|
||||
"PORT": 5432,
|
||||
}
|
||||
|
|
|
@ -31,20 +31,21 @@ services:
|
|||
restart: always
|
||||
|
||||
web:
|
||||
build:
|
||||
context: ./Resources
|
||||
dockerfile: ./docker/web/Dockerfile
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
restart: always
|
||||
command: [nginx-debug, '-g', 'daemon off;']
|
||||
volumes:
|
||||
- ./Resources/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
volumes_from:
|
||||
- app:ro
|
||||
links:
|
||||
- app
|
||||
|
||||
graphql-engine:
|
||||
image: hasura/graphql-engine:v2.0.0-alpha.3
|
||||
image: hasura/graphql-engine:v2.0.0-alpha.5
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
|
@ -58,7 +59,7 @@ services:
|
|||
HASURA_GRAPHQL_ADMIN_SECRET: pokemon
|
||||
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: anon
|
||||
HASURA_GRAPHQL_ENABLE_TELEMETRY: "false"
|
||||
HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
|
||||
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
|
|
Loading…
Reference in a new issue