Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fixed workflow for generating introspection query for docs #578

Merged
merged 7 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/subgraph-documentation-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
node-version: 18
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Generate introspection query result
run: yarn generate:introspection
- name: Generate partial introspection query results for documentation
run: yarn generate:introspection:partial
working-directory: packages/subgraph/
- name: Generate Query Examples docs
run: yarn docs:examples
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Copy the docs/developer-portal folder to the developer-portal
run: cp -R packages/subgraph/docs/developer-portal $GITHUB_WORKSPACE/developer-portal/docs/subgraph
- name: Copy the generated schema-introspection.json to the developer-portal
run: cp -R packages/subgraph/docs/schema-introspection.json $GITHUB_WORKSPACE/developer-portal/static/subgraph
run: cp -R packages/subgraph/docs/schema-introspection-partial.json $GITHUB_WORKSPACE/developer-portal/static/subgraph
- name: Get short commit hash
id: hash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ schema-introspection.json

# docs
packages/subgraph/docs/developer-portal/
schema-introspection-partial.json
4 changes: 2 additions & 2 deletions packages/subgraph/codegen.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generates:
./docs/schema-introspection.json:
schema: ./schema.graphql
./docs/schema-introspection-partial.json:
schema: ./schema.tmp.graphql
plugins:
- introspection
6 changes: 3 additions & 3 deletions packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"deploy": "scripts/deploy-subgraph.sh",
"create:local": "graph create aragon/aragon-core-goerli --node http://localhost:8020",
"deploy:local": "LOCAL=true scripts/deploy-subgraph.sh",
"generate:introspection": "scripts/generate-introspection-json.sh",
"generate:introspection:partial": "graphql-codegen && cd docs && prettier schema-introspection.json --write",
"docs:examples": "node ./scripts/generate-markdown.js ./src/examples && rsync -avr --prune-empty-dirs --remove-source-files --include='*/' --include='*.md' --exclude='*' ./src/examples/ ./docs/developer-portal/ --delete;",
"generate:introspection": "scripts/tests/generate-introspection-json.sh",
"generate:introspection:partial": "scripts/docs/generate-introspection-partial-json.sh",
"docs:examples": "node ./scripts/docs/generate-markdown.js ./src/examples && rsync -avr --prune-empty-dirs --remove-source-files --include='*/' --include='*.md' --exclude='*' ./src/examples/ ./docs/developer-portal/ --delete;",
"start:dev": "docker-compose -f docker/docker-compose.yml up -d && sleep 30 && yarn create:local && yarn deploy:local",
"stop:dev": "docker-compose -f docker/docker-compose.yml down",
"buildAndStart:dev": "docker-compose -f docker/docker-compose.yml up -d --build hardhat && sleep 30 && yarn create:local && yarn deploy:local",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Copy schema.graphql to a temporary file
cp schema.graphql schema.tmp.graphql

# Add lines at the end of the file
cat <<EOF >> schema.tmp.graphql
" Byte array, represented as a hexadecimal string. Commonly used for Ethereum hashes and addresses. "
scalar Bytes
" Large integers. Used for Ethereum's uint32, int64, uint64, ..., uint256 types. Note: Everything below uint32, such as int32, uint24 or int8 is represented as i32. "
scalar BigInt
" Query type, required to generate introspection query. "
type Query @entity {
id: ID!
}
EOF

# Run graphql-codegen
graphql-codegen

# Navigate to the docs directory
cd docs || exit

# Run prettier on schema-introspection-partial.json
prettier schema-introspection-partial.json --write

# Remove the temporary file
cd ..
rm schema.tmp.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ graph create $SUBGRAPH_NAME-$NETWORK_NAME --node http://localhost:8020
# deploy subgraph
LOCAL=true ./scripts/deploy-subgraph.sh
# make introspection json
FILENAME="docs/schema-introspection.json"
FILENAME="tests/utils/schema-introspection.json"
GRAPH_URL="http://localhost:8000/subgraphs/name/$SUBGRAPH_NAME-$NETWORK_NAME"
echo "Fetching introspection query from $GRAPH_URL"
node ./scripts/fetch-introspection-query.js $GRAPH_URL $FILENAME
node ./scripts/tests/fetch-introspection-query.js $GRAPH_URL $FILENAME
prettier $FILENAME --write
# down docker
docker compose -f docker/docker-compose.yml down
Loading