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

chore: introduce query planner to router-bridge #1090

Merged
merged 5 commits into from Oct 15, 2021

Conversation

o0Ignition0o
Copy link
Contributor

@o0Ignition0o o0Ignition0o commented Oct 15, 2021

chore: Introduce query planner to router-bridge

fixes #1088

#1079 Added a new router-bridge that binds together the rust router and some TypeScript / Javascript capabilities (introspection mostly).
This commit is built on top of @BrynCooke 's work on #812, and exposes a query planning functionality, which has been living in a separate branch for a while.

A few things happened:

General:

  • Remove jest tests from the router bridge (they weren't being run anyway, and they are now superseded by the cargo tests)
  • Add router-bridge js files to the prettier configuration for formatting and linting
  • Add a dependency to query-planner-js to the router-bridge

TypeScript/Javascript:

  • Add do_plan.ts that calls the query-planner behind the scenes.
  • Use new QueryPlanner(schema).buildQueryPlan instead of the old buildQueryPlan function, that doesn't exist anymore (depending on how long we want to keep this code, we might be able to keep the QueryPlanner object around, and skip subsequent schema parsing / composing.
  • Move the type OperationResult to a utils file (so we can use it in both do_plan.ts and do_introspect.ts

Rust:

  • Use &str instead of String for schema SDL, since apollo-rs provides as_str() on the Schema type.
  • Add a plan function, that is generic over it's return type ( Result<T, PlanningErrors> where T: DeserializeOwned + 'static so we can keep the QueryPlan structure on the router-core side.
  • Add plan() tests that call plan<serde_json::Value>() so we have snapshots over the plan result.

@o0Ignition0o o0Ignition0o force-pushed the igni/router_bridge_query_planner branch from 4b831ba to 9782a5f Compare October 15, 2021 09:17
@o0Ignition0o o0Ignition0o changed the title wip: introduce query planner to router-bridge chore: introduce query planner to router-bridge Oct 15, 2021
@o0Ignition0o o0Ignition0o force-pushed the igni/router_bridge_query_planner branch from 9782a5f to a843edd Compare October 15, 2021 09:44
@o0Ignition0o o0Ignition0o marked this pull request as ready for review October 15, 2021 09:44
Copy link
Contributor

@BrynCooke BrynCooke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great! I left a few comments, but some are merely suggestions. None of them are truly blocking and I would still consider approving as-is so long via merely some back-and-forth convo, I suspect!

Thanks!

router-bridge/js-src/utils.ts Outdated Show resolved Hide resolved
router-bridge/js-src/index.ts Outdated Show resolved Hide resolved
router-bridge/js-src/plan.ts Outdated Show resolved Hide resolved
router-bridge/js-src/plan.ts Outdated Show resolved Hide resolved
router-bridge/package.json Show resolved Hide resolved
router-bridge/src/testdata/query.graphql Outdated Show resolved Hide resolved
router-bridge/src/testdata/schema.graphql Show resolved Hide resolved
router-bridge/src/testdata/schema.graphql Outdated Show resolved Hide resolved
router-bridge/src/testdata/schema.graphql Outdated Show resolved Hide resolved
Comment on lines -1 to -4
{
"extends": "../tsconfig.test.base",
"include": ["**/__tests__/**/*"],
"references": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly unsure that we should remove this Jest configuration from this repository. Most users of this repo are not running cargo test, but instead working in TypeScript. With this removed, they might not understand a change that they made is breaking until after it goes through CI. Could we avoid that by running something basic that we need (like a simple query plan, possibly copied from existing query plan tests?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind pairing with me on that? I struggled a lot yesterday because whatever i tried to do the jest tests declared in the bridge wouldn't run :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, you're right, if the graphql api or the query-planner-js api changes, we might warn users that we can't run the bridge as intended

@BrynCooke BrynCooke self-requested a review October 15, 2021 10:38
@o0Ignition0o o0Ignition0o force-pushed the igni/router_bridge_query_planner branch 2 times, most recently from bf3c26b to 1be695b Compare October 15, 2021 11:50
fixes #1088

This commit is built on top of @BrynCooke 's work on #812, and exposes a query planning functionality, which has been living in a separate branch for a while.

A few things happened:

General:
- Remove jest tests from the router bridge (they weren't being run anyway, and they are now superseded by the cargo tests)
- Add router-bridge js files to the prettier configuration for formatting and linting
- Add a dependency to query-planner-js to the router-bridge

TypeScript/Javascript:
- Add `do_plan.ts` that calls the query-planner behind the scenes.
- Use `new QueryPlanner(schema).buildQueryPlan` instead of the old `buildQueryPlan` function, that doesn't exist anymore (depending on how long we want to keep this code, we might be able to keep the QueryPlanner object around, and skip subsequent schema parsing / composing.
- Move the type `OperationResult` to a utils file (so we can use it in both `do_plan.ts` and `do_introspect.ts`

Rust:
- Use &str instead of String for schema SDL, since apollo-rs provides as_str() on the Schema type.
- Add a plan function, that is generic over it's return type ( `Result<T, PlanningErrors>` where `T: DeserializeOwned + 'static` so we can keep the `QueryPlan` structure on the router-core side.
- Add plan() tests that call plan<serde_json::Value>() so we have snapshots over the plan result.
Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legend!

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.

Add query planner to router-bridge
3 participants