Experimantal GraphQL Endpoint

Review Request #12036 — Created Feb. 4, 2022 and discarded — Latest diff uploaded

Information

Review Board
master

Reviewers

Add an experimental GraphQL API endpoint.

This change introduces a new endpoint at /graphql, which handles GraphQL requests. The endpoint accepts POST requests with the body containing a valid GraphQL query. The schema for the API is generated by functions that map existing WebAPIResource's into GraphQL types. This change also includes the query resolvers, which are called by the py-gql function graphql_blocking, that query, filter, and return data from the database. Currently, only the User and ReviewRequest objects have been defined in the schema and have resolvers.

The filtering logic in resolve_review_requests uses essentially the same logic as the filtering in the review_request resource, with some slight changes due to the difference in GrapgQL schema and REST query parameters. Ideally, this code would be refactored and DRY'ed out. Additionally, when building the schema we may eventually want to define the ResourceList and Resource types as a nested type, to take full advantage of the technology. For now, these are typed as objects with href, method, and title as they currently are in the other API resources.

Added unit tests for GraphQLResource and the User, Users, ReviewRequest, and ReviewRequests resolvers.
Ran all reviewboard tests.

Changes between revision 8 and 9

orig
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Commits

Summary ID Author
Experimantal GraphQL Endpoint
46378a7521ac685e9a4eb32c1988b8adfd787bb5 Dalton Ronan
Experimantal GraphQL Endpoint
6b5b73f8edb805f90ed680fe53960a2df323b896 Dalton Ronan
reviewboard/dependencies.py
reviewboard/webapi/resources/graphql.py
reviewboard/webapi/resources/root.py
reviewboard/webapi/tests/mimetypes.py
reviewboard/webapi/tests/test_graphql.py
reviewboard/webapi/tests/urls.py
Loading...