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

WIP: New crate implementing execution and schema introspection #645

Closed
wants to merge 5 commits into from

Conversation

SimonSapin
Copy link
Contributor

Note: this depends on ongoing work for #641, so for now this PR targets a temporary branch in order to only show relevant diffs.


This is an initial draft implementation of (trying to be) spec-compliant:

  • Execution:

    • A trait abstraction for objects with asynchronously resolvable fields
    • Input coercion / type checking of variable values and argument values
    • Field collection (handling @skip, @include, and type conditions)
    • Handling of field error (collecting the relevant path, propagating null), raised by a resolver or otherwise
    • Result coercion / type checking of response data
    • serde-serializable data structures of a GraphQL response, request errors, field errors, and field error path
    • JSON data for variable values and response data is represented with serde_json_bytes::Value (which uses a wrapper of reference-counted Bytes for strings)
  • Schema introspection:

    • Removing and collecting schema introspection selections (__schema and __type) from an executable document, so the rest can be executed separately (whether with the above, or not like in Apollo Router)
    • Execution of those collected selections, returning a response that can be merged with the response for the rest of the request

See crates/apollo-introspection/tests/doc_example.rs for an API usage example.

Testing is minimal. Experience integrating with Apollo Router would be good to have before merging this PR. Execution is included in support of introspection and not exposed in the public API. If/when another use case comes we can expose it, with some more thought on the API design (especially for the resolver trait).

@SimonSapin SimonSapin self-assigned this Sep 18, 2023
@SimonSapin SimonSapin force-pushed the introspection branch 2 times, most recently from f96a8ca to 6d97e54 Compare September 27, 2023 13:12
@SimonSapin SimonSapin changed the base branch from mut to compiler-v1.0 October 4, 2023 13:54
This was referenced Oct 4, 2023
@SimonSapin SimonSapin changed the base branch from compiler-v1.0 to main October 12, 2023 10:06
@SimonSapin
Copy link
Contributor Author

Input coercion / type checking of variable values and argument values

Apollo Router has roughly the same functionality in a function called validate_input_value. As part of introspection work, let’s have apollo-rs expose input coercion in a way that can be used by the Router instead of validate_input_value.

@SimonSapin
Copy link
Contributor Author

Moved to #758

@SimonSapin SimonSapin closed this Nov 23, 2023
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