-
Notifications
You must be signed in to change notification settings - Fork 45
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
compiler: should definitions know their own name? #708
Labels
apollo-compiler
issues/PRs pertaining to semantic analysis & validation
Comments
SimonSapin
added
the
apollo-compiler
issues/PRs pertaining to semantic analysis & validation
label
Oct 19, 2023
We’d like So proposed plan:
|
SimonSapin
added a commit
that referenced
this issue
Nov 7, 2023
Fixes #708 In a few places (but not consistently) a `name` field was omitted from some structs used as map values on the basis that it would have been redundant with the map key. This reverts that decision, making it the user’s responsibility when mutating documents to keep names consistent. * Add a `pub name: Name` field to `executable::Fragment` as well as `ScalarType`, `ObjectType`, `InterfaceType`, `EnumType`, `UnionType`, and `InputObjectType` in `schema`. * Add a `fn name(&self) -> &Name` method to the `schema::ExtendedType` enum * Add a `pub fn name: Option<Name>` field to `executable::Operation` * Remove `executable::OperationRef<'_>` (which was equivalent to `(Option<&Name>, &Node<Operation>)`), replacing its uses with `&Node<Operation>`
SimonSapin
added a commit
that referenced
this issue
Nov 7, 2023
Fixes #708 In a few places (but not consistently) a `name` field was omitted from some structs used as map values on the basis that it would have been redundant with the map key. This reverts that decision, making it the user’s responsibility when mutating documents to keep names consistent. * Add a `pub name: Name` field to `executable::Fragment` as well as `ScalarType`, `ObjectType`, `InterfaceType`, `EnumType`, `UnionType`, and `InputObjectType` in `schema`. * Add a `fn name(&self) -> &Name` method to the `schema::ExtendedType` enum * Add a `pub name: Option<Name>` field to `executable::Operation` * Remove `executable::OperationRef<'_>` (which was equivalent to `(Option<&Name>, &Node<Operation>)`), replacing its uses with `&Node<Operation>`
SimonSapin
added a commit
that referenced
this issue
Nov 7, 2023
Fixes #708 In a few places (but not consistently) a `name` field was omitted from some structs used as map values on the basis that it would have been redundant with the map key. This reverts that decision, making it the user’s responsibility when mutating documents to keep names consistent. * Add a `pub name: Name` field to `executable::Fragment` as well as `ScalarType`, `ObjectType`, `InterfaceType`, `EnumType`, `UnionType`, and `InputObjectType` in `schema`. * Add a `fn name(&self) -> &Name` method to the `schema::ExtendedType` enum * Add a `pub name: Option<Name>` field to `executable::Operation` * Remove `executable::OperationRef<'_>` (which was equivalent to `(Option<&Name>, &Node<Operation>)`), replacing its uses with `&Node<Operation>`
SimonSapin
added a commit
that referenced
this issue
Nov 9, 2023
* Make everything know their own name Fixes #708 In a few places (but not consistently) a `name` field was omitted from some structs used as map values on the basis that it would have been redundant with the map key. This reverts that decision, making it the user’s responsibility when mutating documents to keep names consistent. * Add a `pub name: Name` field to `executable::Fragment` as well as `ScalarType`, `ObjectType`, `InterfaceType`, `EnumType`, `UnionType`, and `InputObjectType` in `schema`. * Add a `fn name(&self) -> &Name` method to the `schema::ExtendedType` enum * Add a `pub name: Option<Name>` field to `executable::Operation` * Remove `executable::OperationRef<'_>` (which was equivalent to `(Option<&Name>, &Node<Operation>)`), replacing its uses with `&Node<Operation>` * clippy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of 1.0.0-beta.4, the
Schema
struct containstypes: IndexMap<Name, ExtendedType>
. Each variant of theExtendedType
enum is a struct like this:Notably, these type definition structs do not contain a
name: Name
field. The reasoning is that the name is already in the map key, so having it in the struct as well would be redundant. And with a mutable data structure, eliminating redundancy eliminates the possibility of inconsistencies.However:
FieldDefintion
is reused from the AST and does contain aname
field, despite being in a name-indexed map when in a high-levelSchema
representation.I think we should pick one pattern and apply it everywhere. Either nothing in
IndexMap<Name, …>
should duplicate its name (and have more dedicated structs in theschema
module forFieldDefinition
and others, instead of reusing AST ones), or everything should. Either way, this is breaking change that needs to happen before 1.0 leaves beta (or not happen).The text was updated successfully, but these errors were encountered: