-
Notifications
You must be signed in to change notification settings - Fork 639
chore: add test qrapg QL query workflow #6920
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Test GraphQL Queries | ||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test-query: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - 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 }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.