From 2214877b50b05e68e697be7edfdfca0dbf335b77 Mon Sep 17 00:00:00 2001 From: Marie Lucca Date: Mon, 29 Sep 2025 11:58:59 -0400 Subject: [PATCH 1/3] chore: add test qrapg QL query workflow --- .github/workflows/graphql-test.yml | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/graphql-test.yml diff --git a/.github/workflows/graphql-test.yml b/.github/workflows/graphql-test.yml new file mode 100644 index 00000000000..cf19007b4f4 --- /dev/null +++ b/.github/workflows/graphql-test.yml @@ -0,0 +1,86 @@ +name: Test GraphQL Queries +on: + workflow_dispatch: + +jobs: + test-query: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + fetch-depth: 0 + + - name: Test GraphQL Query + run: | + echo "Testing GraphQL query against GitHub API..." + + # Test query to get repository information + QUERY='query { + repository(owner: "primer", name: "react") { + name + description + stargazerCount + forkCount + defaultBranchRef { + name + } + languages(first: 5) { + nodes { + name + color + } + } + } + }' + + # Make the GraphQL API call with detailed error logging + echo "Making GraphQL API call..." + HTTP_STATUS=$(curl -w "%{http_code}" -s -X POST \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{\"query\": \"$(echo $QUERY | tr '\n' ' ' | sed 's/"/\\"/g')\"}" \ + -o response.json \ + https://api.github.com/graphql) + + RESPONSE=$(cat response.json) + + echo "HTTP Status Code: $HTTP_STATUS" + echo "Full GraphQL Response:" + echo "$RESPONSE" | jq '.' || echo "Raw response (invalid JSON): $RESPONSE" + + # Check HTTP status first + if [ "$HTTP_STATUS" != "200" ]; then + echo "❌ HTTP request failed with status code: $HTTP_STATUS" + echo "Full response body:" + echo "$RESPONSE" + exit 1 + fi + + # Check if the response contains GraphQL errors + if echo "$RESPONSE" | jq -e '.errors' > /dev/null 2>&1; then + echo "❌ GraphQL query returned errors:" + echo "$RESPONSE" | jq '.errors' + echo "Full error details:" + echo "$RESPONSE" | jq '.errors[] | {message: .message, type: .type, path: .path, locations: .locations}' || true + exit 1 + fi + + # Check if the query was successful and has expected data + if echo "$RESPONSE" | jq -e '.data.repository.name' > /dev/null 2>&1; then + echo "✅ GraphQL query executed successfully!" + echo "Repository name: $(echo "$RESPONSE" | jq -r '.data.repository.name')" + echo "Stars: $(echo "$RESPONSE" | jq -r '.data.repository.stargazerCount')" + echo "Default branch: $(echo "$RESPONSE" | jq -r '.data.repository.defaultBranchRef.name')" + else + echo "❌ GraphQL query failed - no valid data returned" + echo "Expected data.repository.name but got:" + echo "$RESPONSE" | jq '.data // "No data field found"' + exit 1 + fi + + # Cleanup + rm -f response.json + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From fab4b0236a6fc75a12133248e7d34114043c7b76 Mon Sep 17 00:00:00 2001 From: Marie Lucca <40550942+francinelucca@users.noreply.github.com> Date: Mon, 29 Sep 2025 12:10:01 -0400 Subject: [PATCH 2/3] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/graphql-test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/graphql-test.yml b/.github/workflows/graphql-test.yml index cf19007b4f4..51f2969ee2e 100644 --- a/.github/workflows/graphql-test.yml +++ b/.github/workflows/graphql-test.yml @@ -9,9 +9,6 @@ jobs: - name: Checkout repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 with: - # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits - fetch-depth: 0 - - name: Test GraphQL Query run: | echo "Testing GraphQL query against GitHub API..." From 48acc32f070be20670f0cb9db1b71b1416806bc9 Mon Sep 17 00:00:00 2001 From: Marie Lucca Date: Mon, 29 Sep 2025 12:15:17 -0400 Subject: [PATCH 3/3] remove unnecessary step --- .github/workflows/graphql-test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/graphql-test.yml b/.github/workflows/graphql-test.yml index 51f2969ee2e..f1969b8a870 100644 --- a/.github/workflows/graphql-test.yml +++ b/.github/workflows/graphql-test.yml @@ -6,9 +6,6 @@ jobs: test-query: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - with: - name: Test GraphQL Query run: | echo "Testing GraphQL query against GitHub API..."