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

add union types to schema #309

Merged
merged 7 commits into from
Jan 13, 2024

Conversation

fprasx
Copy link
Contributor

@fprasx fprasx commented Jan 10, 2024

  • Add union to schema
  • Update adapter

Fixes #36.

@obi1kenobi
Copy link
Owner

The schema is reasonable 👍

Make sure to both update the adapter and the index lookup optimizations, otherwise we might end up in a situation where index lookups fail to find unions that otherwise get returned when the optimization isn't used.

Lmk if you get stuck on anything or would like to chat about anything.

@fprasx
Copy link
Contributor Author

fprasx commented Jan 10, 2024

Sounds good. I'm basically just grepping for union/struct and adding union.

@fprasx fprasx marked this pull request as ready for review January 10, 2024 21:43
@fprasx fprasx force-pushed the fprasx/add-unions-to-schema branch from 00bde00 to 7602fbc Compare January 10, 2024 21:47
@fprasx
Copy link
Contributor Author

fprasx commented Jan 10, 2024

Ok, the meat of it is there.

I'm not too familiar with the codebase, do you know if there are any specific union-related tests I should add, off the top of your head?

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

do you know if there are any specific union-related tests I should add

I'd add a test crate with some unions, and then make sure:

  • querying for all unions and their fields returns correct data
  • querying for union importable paths returns correct data (even with re-exports)
  • querying unions by importable path returns correct data (this will use the fast paths and use an index lookup optimization)

src/adapter/mod.rs Show resolved Hide resolved
@fprasx fprasx force-pushed the fprasx/add-unions-to-schema branch from dd87126 to 0e562b7 Compare January 11, 2024 01:26
@fprasx
Copy link
Contributor Author

fprasx commented Jan 11, 2024

Hmm, it actually seems less disruptive to just test union where struct/enum are getting tested in the crates that exist right now, for example:

querying for union importable paths returns correct data (even with re-exports)

can be tested in the importable_paths test crate, where it's tested for struct/enum

This test case is also included in this commit as it exposed the bug.
@obi1kenobi
Copy link
Owner

Let me know when this is ready for another review!

@obi1kenobi
Copy link
Owner

can be tested in the importable_paths test crate, where it's tested for struct/enum

btw, make sure to check out that test case, because I'm not sure it's testing quite what we might be assuming it's testing here

@fprasx
Copy link
Contributor Author

fprasx commented Jan 11, 2024

You're right, I did some more digging into the test crates, and that one is testing something else. I've actually come to your original conclusion post-dig, which is that it's just simpler to have a crate for unions. Because structs and enums were there from the beginning, there are no specific tests for them, rather they're just used everywhere. Since unions are new their introduction might cause some bugs so they can get ~their own crate~.

I've gotta a pretty busy day today, so I might not be able to finish this up today, but I'll try to get it done by the weekend!

@obi1kenobi
Copy link
Owner

Sounds good! Thanks for setting expectations explicitly as well, it'll help me plan my own day as well.

@fprasx
Copy link
Contributor Author

fprasx commented Jan 13, 2024

Ok, added a test crate. I think I've covered everything (importing, visibility, field info), but not sure.

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

Awesome, ship it! 🚀

@obi1kenobi obi1kenobi merged commit 66a0ca9 into obi1kenobi:rustdoc-v28 Jan 13, 2024
6 checks passed
obi1kenobi pushed a commit that referenced this pull request Jan 13, 2024
* add union types to schema

* add union support to adapter

* avoid extra indirection when resolving union edge

* add union to supported item kinds

* resolve __typename of unions

This test case is also included in this commit as it exposed the bug.

* add unions to some glob test cases

* add tests
obi1kenobi pushed a commit that referenced this pull request Jan 13, 2024
* add union types to schema

* add union support to adapter

* avoid extra indirection when resolving union edge

* add union to supported item kinds

* resolve __typename of unions

This test case is also included in this commit as it exposed the bug.

* add unions to some glob test cases

* add tests
@obi1kenobi
Copy link
Owner

I've used a bit of magic automation to port this PR to rustdoc-v27 and rustdoc-v26, and I'll release new versions for all three so that the next cargo update in cargo-semver-checks picks them up automatically.

obi1kenobi added a commit that referenced this pull request Jan 13, 2024
* add union types to schema

* add union support to adapter

* avoid extra indirection when resolving union edge

* add union to supported item kinds

* resolve __typename of unions

This test case is also included in this commit as it exposed the bug.

* add unions to some glob test cases

* add tests

Co-authored-by: Felix Prasanna <91577249+fprasx@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Jan 13, 2024
* add union types to schema

* add union support to adapter

* avoid extra indirection when resolving union edge

* add union to supported item kinds

* resolve __typename of unions

This test case is also included in this commit as it exposed the bug.

* add unions to some glob test cases

* add tests

Co-authored-by: Felix Prasanna <91577249+fprasx@users.noreply.github.com>
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.

Implement the Union type, making union types queriable
2 participants