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

Improve error handling of allProjectsByFunction #4483

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

IvanIvanoff
Copy link
Member

@IvanIvanoff IvanIvanoff commented Nov 21, 2024

Changes

Properly propagate the error when the watchlist from the JSON arguments is not existing.

query($fn:json){
    allProjectsByFunction(function: $fn) {
      projects {
        slug name ticker
    }
  }
}
{
  "fn": "{\"name\":\"selector\",\"args\":{\"baseProjects\":[{\"watchlistId\":5496}],\"filters\":[],\"orderBy\":{\"aggregation\":\"avg\",\"dynamicFrom\":\"7d\",\"direction\":\"desc\",\"dynamicTo\":\"now\",\"metric\":\"dev_activity_1d\"},\"pagination\":{\"page\":1,\"pageSize\":10}}}"
}

Old response:

{
  "errors": {
    "details": "Internal server error"
  }
}

New response:

{
  "data": {
    "allProjectsByFunction": null
  },
  "errors": [
    {
      "message": "Watchlist with id 5496 does not exist",
      "path": [
        "allProjectsByFunction"
      ],
      "locations": [
        {
          "line": 2,
          "column": 5
        }
      ]
    }
  ]
}

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

@IvanIvanoff IvanIvanoff force-pushed the do-not-raise-on-non-existing-watchlist branch from 1ea0fad to c00e431 Compare November 21, 2024 13:19
@IvanIvanoff IvanIvanoff merged commit 870c7a9 into master Nov 21, 2024
4 checks passed
@IvanIvanoff IvanIvanoff deleted the do-not-raise-on-non-existing-watchlist branch November 21, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants