File tree Expand file tree Collapse file tree 6 files changed +84
-0
lines changed
Expand file tree Collapse file tree 6 files changed +84
-0
lines changed Original file line number Diff line number Diff line change 1+ THEGRAPH_GATEWAY_DOMAIN = " gateway.thegraph.com"
2+ THEGRAPH_API_KEY =
Original file line number Diff line number Diff line change 1+ # TheGraph Proxy
2+
3+ > ⚠️ Use this component for development purpose only
4+
5+ Proxy server component relaying the calls to the decentralized thegraph network
6+
7+ ## Usage
8+
9+ ### prepare the ` .env ` file
10+
11+ ``` sh
12+ cp .env.template .env
13+ ```
14+
15+ fill in ` THEGRAPH_API_KEY ` in the generated [ .env] ( .env )
16+
17+ ### launch the ** thegraph-proxy** service
18+
19+ ``` sh
20+ docker compose up -d
21+ ```
22+
23+ The service is available at < http://localhost:8080 >
24+
25+ ### use the service to query a subgraph
26+
27+ example
28+
29+ ``` js
30+ curl -- request POST \
31+ -- url http: // localhost:8080/subgraphs/id/2GCj8gzLCihsiEDq8cYvC5nUgK6VfwZ6hm3Wj8A3kcxz \
32+ -- data ' {"query":"query {\n\t _meta {\n\t\t deployment\n\t\t hasIndexingErrors\n\t\t block {\n\t\t\t number\n\t\t }\n\t }\n }\n "}'
33+ ```
34+
35+ ### stop the service
36+
37+ ``` sh
38+ docker compose down
39+ ```
Original file line number Diff line number Diff line change 1+ services :
2+ thegraph-proxy :
3+ image : thegraph-proxy
4+ build :
5+ context : ./docker
6+ dockerfile : Dockerfile
7+ restart : unless-stopped
8+ ports :
9+ - ' 8080:80'
10+ environment :
11+ THEGRAPH_GATEWAY_DOMAIN : ${THEGRAPH_GATEWAY_DOMAIN}
12+ THEGRAPH_API_KEY : ${THEGRAPH_API_KEY}
Original file line number Diff line number Diff line change 1+ FROM nginx:alpine
2+
3+ # Install envsubst (part of gettext)
4+ RUN apk add --no-cache gettext
5+
6+ # Copy config template and entrypoint script
7+ COPY default.conf.template /etc/nginx/templates/default.conf.template
8+ COPY entrypoint.sh /docker-entrypoint.d/entrypoint.sh
9+
10+ # Make sure entrypoint is executable
11+ RUN chmod +x /docker-entrypoint.d/entrypoint.sh
Original file line number Diff line number Diff line change 1+ server {
2+ listen 80;
3+
4+ location / {
5+ proxy_pass https://${THEGRAPH_GATEWAY_DOMAIN}/api/${THEGRAPH_API_KEY}/;
6+
7+ proxy_ssl_server_name on;
8+
9+ proxy_set_header Host ${THEGRAPH_GATEWAY_DOMAIN};
10+ proxy_set_header X-Real-IP $remote_addr;
11+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Replace env vars in template and save to nginx config dir
4+ envsubst ' $THEGRAPH_GATEWAY_DOMAIN $THEGRAPH_API_KEY' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf
5+
6+ # Start nginx (inherited from base image entrypoint)
7+ exec " $@ "
You can’t perform that action at this time.
0 commit comments