tweag / nixpkgs-graph-explorer

Explore the nixpkgs dependency graph
MIT License
15 stars 0 forks source link

Update gremlin query logic to use stricter typing #53

Closed dorranh closed 1 year ago

dorranh commented 1 year ago

This PR updates both the /gremlin FastAPI endpoint and related core logic in explorer.queries.query to make the typing more explicit. The allows for more detailed type checking with pyright and helps open up the possibility of generating OpenAPI documentation for this endpoint via FastAPI.

In order to do this, I had to add additional pydantic types to explorer.queries.query and introduce a new module containing a subset of the cytoscape.js data model.

In order to test that query.GremlinResult was still working, I had to implement a method for inserting edges into the graph (and related tests). This will hopefully serve as a basis for porting the ETL logic from etl to api as described in #42.

In addition to the unit tests I have also manually tested this with the front-end to ensure that it is compatible with the changes to the API (I made one small tweak to the cytoscape config (https://github.com/tweag/nixpkgs-graph-explorer/commit/77a20cf112c5ab39d38437732c72f44942083510).