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

Schema types to implement Hash #792

Closed
BrynCooke opened this issue Dec 21, 2023 · 4 comments
Closed

Schema types to implement Hash #792

BrynCooke opened this issue Dec 21, 2023 · 4 comments

Comments

@BrynCooke
Copy link
Contributor

It looks like the schema types such as ObjectType, InterfaceType etc do not currently implement Hash.
It would be super useful if they did so as it is likely that users will want to create lookups from graphql schema types to other datastructures.

ScalarType alone does implement Hash.

@SimonSapin
Copy link
Contributor

These impls can’t be derived because IndexMap and IndexSet don’t implement Hash. Though perhaps the well-defined iteration order would make it easier to define a meaningful hash for IndexMap than HashMap.

In what kind of situation do you want to use a full definition with all of its details as a map key? As opposed to using only the name as a key, in the implicit context of a specific schema.

@BrynCooke
Copy link
Contributor Author

I can imagine a situation where you would want to attach extra data to schema elements. As this isn't possible right now my first instinct was to use the objects as a key in a map.
Are types unique within a schema? If so maybe it would make sense that Hash should not be deep and only use the name.
Agree that users can maintain a separate datastructure to allow decoration of schema elements though, so happy to close.

@SimonSapin
Copy link
Contributor

Yes, type definitions have unique names within a high-level Schema (not necessarily in a lower-level AST Document).

I’m not sure about implementing Hash for a definition by only hashing the name, as opposed to having users explicitly use names as keys. Something like composition can manipulate multiple (subgraph) schemas where the same type name can have different definitions.

@BrynCooke
Copy link
Contributor Author

Let's close this then.

@abernix abernix removed the triage label Jan 5, 2024
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

No branches or pull requests

3 participants