diff --git a/.github/workflows/subgraph-documentation-update.yml b/.github/workflows/subgraph-documentation-update.yml index 3ccb42422..7c9153f09 100644 --- a/.github/workflows/subgraph-documentation-update.yml +++ b/.github/workflows/subgraph-documentation-update.yml @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index 18cf293a0..fa68b87eb 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ schema-introspection.json # docs packages/subgraph/docs/developer-portal/ +schema-introspection-partial.json diff --git a/packages/subgraph/codegen.yml b/packages/subgraph/codegen.yml index 5435244ea..84c4ce308 100644 --- a/packages/subgraph/codegen.yml +++ b/packages/subgraph/codegen.yml @@ -1,5 +1,5 @@ generates: - ./docs/schema-introspection.json: - schema: ./schema.graphql + ./docs/schema-introspection-partial.json: + schema: ./schema.tmp.graphql plugins: - introspection diff --git a/packages/subgraph/package.json b/packages/subgraph/package.json index dd74bef1d..2e9657735 100644 --- a/packages/subgraph/package.json +++ b/packages/subgraph/package.json @@ -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", diff --git a/packages/subgraph/scripts/docs/generate-introspection-partial-json.sh b/packages/subgraph/scripts/docs/generate-introspection-partial-json.sh new file mode 100755 index 000000000..d3f6ea3d0 --- /dev/null +++ b/packages/subgraph/scripts/docs/generate-introspection-partial-json.sh @@ -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 <> 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 diff --git a/packages/subgraph/scripts/generate-markdown.js b/packages/subgraph/scripts/docs/generate-markdown.js similarity index 100% rename from packages/subgraph/scripts/generate-markdown.js rename to packages/subgraph/scripts/docs/generate-markdown.js diff --git a/packages/subgraph/scripts/fetch-introspection-query.js b/packages/subgraph/scripts/tests/fetch-introspection-query.js similarity index 100% rename from packages/subgraph/scripts/fetch-introspection-query.js rename to packages/subgraph/scripts/tests/fetch-introspection-query.js diff --git a/packages/subgraph/scripts/generate-introspection-json.sh b/packages/subgraph/scripts/tests/generate-introspection-json.sh similarity index 90% rename from packages/subgraph/scripts/generate-introspection-json.sh rename to packages/subgraph/scripts/tests/generate-introspection-json.sh index 63ffc10d0..00367a739 100755 --- a/packages/subgraph/scripts/generate-introspection-json.sh +++ b/packages/subgraph/scripts/tests/generate-introspection-json.sh @@ -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