From f5ed933c8d20963c51a97c2e62f39f1e79440b5d Mon Sep 17 00:00:00 2001 From: banasa44 Date: Tue, 23 Apr 2024 17:16:07 +0200 Subject: [PATCH 1/7] feat: .sh to generate a temp.schema to generate introspection.json --- .../subgraph-documentation-update.yml | 4 +-- packages/subgraph/codegen.yml | 2 +- packages/subgraph/package.json | 2 +- .../generate-introspection-partial-json.sh | 29 +++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100755 packages/subgraph/scripts/generate-introspection-partial-json.sh diff --git a/.github/workflows/subgraph-documentation-update.yml b/.github/workflows/subgraph-documentation-update.yml index 3ccb42422..bec59f276 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 result for documentation + run: yarn generate:introspection:partial working-directory: packages/subgraph/ - name: Generate Query Examples docs run: yarn docs:examples diff --git a/packages/subgraph/codegen.yml b/packages/subgraph/codegen.yml index 5435244ea..b02f436e7 100644 --- a/packages/subgraph/codegen.yml +++ b/packages/subgraph/codegen.yml @@ -1,5 +1,5 @@ generates: ./docs/schema-introspection.json: - schema: ./schema.graphql + schema: ./schema.tmp.graphql plugins: - introspection diff --git a/packages/subgraph/package.json b/packages/subgraph/package.json index dd74bef1d..074bfb381 100644 --- a/packages/subgraph/package.json +++ b/packages/subgraph/package.json @@ -15,7 +15,7 @@ "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", + "generate:introspection:partial": "scripts/generate-introspection-partial-json.sh", "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;", "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", diff --git a/packages/subgraph/scripts/generate-introspection-partial-json.sh b/packages/subgraph/scripts/generate-introspection-partial-json.sh new file mode 100755 index 000000000..edef57f80 --- /dev/null +++ b/packages/subgraph/scripts/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 beginning 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.json +prettier schema-introspection.json --write + +# Remove the temporary file +cd .. +rm schema.tmp.graphql From 17274bc5059761aad1dd701173e0169f1e8a1b17 Mon Sep 17 00:00:00 2001 From: banasa44 Date: Tue, 23 Apr 2024 17:36:48 +0200 Subject: [PATCH 2/7] ci: rename file to avoid collisions --- .github/workflows/subgraph-documentation-update.yml | 2 +- packages/subgraph/codegen.yml | 2 +- .../subgraph/scripts/generate-introspection-partial-json.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/subgraph-documentation-update.yml b/.github/workflows/subgraph-documentation-update.yml index bec59f276..73f8069c1 100644 --- a/.github/workflows/subgraph-documentation-update.yml +++ b/.github/workflows/subgraph-documentation-update.yml @@ -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/packages/subgraph/codegen.yml b/packages/subgraph/codegen.yml index b02f436e7..84c4ce308 100644 --- a/packages/subgraph/codegen.yml +++ b/packages/subgraph/codegen.yml @@ -1,5 +1,5 @@ generates: - ./docs/schema-introspection.json: + ./docs/schema-introspection-partial.json: schema: ./schema.tmp.graphql plugins: - introspection diff --git a/packages/subgraph/scripts/generate-introspection-partial-json.sh b/packages/subgraph/scripts/generate-introspection-partial-json.sh index edef57f80..3c580b2ea 100755 --- a/packages/subgraph/scripts/generate-introspection-partial-json.sh +++ b/packages/subgraph/scripts/generate-introspection-partial-json.sh @@ -22,7 +22,7 @@ graphql-codegen cd docs || exit # Run prettier on schema-introspection.json -prettier schema-introspection.json --write +prettier schema-introspection-partial.json --write # Remove the temporary file cd .. From 4f14b1afac61986a4d2b96d32b56a0d715b3d623 Mon Sep 17 00:00:00 2001 From: banasa44 Date: Wed, 24 Apr 2024 10:39:38 +0200 Subject: [PATCH 3/7] ci: move schema-introspection for query examples --- .gitignore | 1 + packages/subgraph/scripts/generate-introspection-json.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 18cf293a0..7f8884bd5 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ schema-introspection.json # docs packages/subgraph/docs/developer-portal/ +schema-introspection-partial.json \ No newline at end of file diff --git a/packages/subgraph/scripts/generate-introspection-json.sh b/packages/subgraph/scripts/generate-introspection-json.sh index 63ffc10d0..50a07c54c 100755 --- a/packages/subgraph/scripts/generate-introspection-json.sh +++ b/packages/subgraph/scripts/generate-introspection-json.sh @@ -34,7 +34,7 @@ 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 From 024047697e52af83b7ca4c314bfbb54a7d3de0ac Mon Sep 17 00:00:00 2001 From: banasa44 Date: Wed, 24 Apr 2024 10:53:04 +0200 Subject: [PATCH 4/7] fix: fix some comments in generate-intros-partial script --- .../subgraph/scripts/generate-introspection-partial-json.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/subgraph/scripts/generate-introspection-partial-json.sh b/packages/subgraph/scripts/generate-introspection-partial-json.sh index 3c580b2ea..d3f6ea3d0 100755 --- a/packages/subgraph/scripts/generate-introspection-partial-json.sh +++ b/packages/subgraph/scripts/generate-introspection-partial-json.sh @@ -3,7 +3,7 @@ # Copy schema.graphql to a temporary file cp schema.graphql schema.tmp.graphql -# Add lines at the beginning of the file +# 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 @@ -21,7 +21,7 @@ graphql-codegen # Navigate to the docs directory cd docs || exit -# Run prettier on schema-introspection.json +# Run prettier on schema-introspection-partial.json prettier schema-introspection-partial.json --write # Remove the temporary file From b3e7e098820ac277087659d31a29ec53a72408a3 Mon Sep 17 00:00:00 2001 From: Carles <75954325+banasa44@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:04:14 +0200 Subject: [PATCH 5/7] Update .gitignore Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7f8884bd5..fa68b87eb 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,4 @@ schema-introspection.json # docs packages/subgraph/docs/developer-portal/ -schema-introspection-partial.json \ No newline at end of file +schema-introspection-partial.json From 381163c61c01ba5e0e952d161b093c254de2d1f5 Mon Sep 17 00:00:00 2001 From: Carles <75954325+banasa44@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:47:55 +0200 Subject: [PATCH 6/7] Update .github/workflows/subgraph-documentation-update.yml Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> --- .github/workflows/subgraph-documentation-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/subgraph-documentation-update.yml b/.github/workflows/subgraph-documentation-update.yml index 73f8069c1..7c9153f09 100644 --- a/.github/workflows/subgraph-documentation-update.yml +++ b/.github/workflows/subgraph-documentation-update.yml @@ -28,7 +28,7 @@ jobs: node-version: 18 - name: Install dependencies run: yarn install --frozen-lockfile - - name: Generate partial introspection query result for documentation + - name: Generate partial introspection query results for documentation run: yarn generate:introspection:partial working-directory: packages/subgraph/ - name: Generate Query Examples docs From ef3e3c864bed97ca2fd77be33e9d376b50324cc7 Mon Sep 17 00:00:00 2001 From: banasa44 Date: Fri, 3 May 2024 15:12:12 +0200 Subject: [PATCH 7/7] chore: move scripts inside /cripts |- /docs and /tests folders --- packages/subgraph/package.json | 6 +++--- .../{ => docs}/generate-introspection-partial-json.sh | 0 packages/subgraph/scripts/{ => docs}/generate-markdown.js | 0 .../scripts/{ => tests}/fetch-introspection-query.js | 0 .../scripts/{ => tests}/generate-introspection-json.sh | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename packages/subgraph/scripts/{ => docs}/generate-introspection-partial-json.sh (100%) rename packages/subgraph/scripts/{ => docs}/generate-markdown.js (100%) rename packages/subgraph/scripts/{ => tests}/fetch-introspection-query.js (100%) rename packages/subgraph/scripts/{ => tests}/generate-introspection-json.sh (94%) diff --git a/packages/subgraph/package.json b/packages/subgraph/package.json index 074bfb381..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": "scripts/generate-introspection-partial-json.sh", - "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/generate-introspection-partial-json.sh b/packages/subgraph/scripts/docs/generate-introspection-partial-json.sh similarity index 100% rename from packages/subgraph/scripts/generate-introspection-partial-json.sh rename to packages/subgraph/scripts/docs/generate-introspection-partial-json.sh 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 94% rename from packages/subgraph/scripts/generate-introspection-json.sh rename to packages/subgraph/scripts/tests/generate-introspection-json.sh index 50a07c54c..00367a739 100755 --- a/packages/subgraph/scripts/generate-introspection-json.sh +++ b/packages/subgraph/scripts/tests/generate-introspection-json.sh @@ -37,7 +37,7 @@ LOCAL=true ./scripts/deploy-subgraph.sh 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