-
Notifications
You must be signed in to change notification settings - Fork 46
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
feat(compiler): add schema coordinates #757
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there other kinds of schema coordinates that diagnostics could use too? Like enum value definition, or implements
of an interface by an object type, etc.
I tend to prefer structured data over stringly-typed, but if the main purpose is to be formatted into a string anyway 🤷 I don’t think 3× refcount traffic is very significant compared to allocating a new string. Do you think size_of::<SchemaCoordinate>()
is something to worry about? We may care less (to some extent) about performance of reporting errors than about validation performance of valid schemas/documents.
@sachindshinde I think I already asked but sorry I don’t remember the conclusion 😅 Is there overlap between this and federation-next’s referencers/positions? Any change you’d suggest here?
Oh hmm, a So you can have |
I think for pointing out a specific For example, if you do something like type Example {
name @deprecated(reason: false)
} you could get an error with its location at coordinate
(would need some copy workshopping to make it read well) |
Something else you can't point to is a schema definition, so we couldn't require a coordinate for diagnostics on those e; As discussed in the call, the initial use for this would be for diagnostic messages, not really as a substitute for location information. |
57bb158
to
2df64d5
Compare
We usually want to keep the old coordinate around. Clone the names inside the methods instead of moving them.
Also use a separate diagnostic with a better message for missing fields on input objects.
a57c000
to
e31daec
Compare
As discussed in checkin, we keep lookup out for now, since we aren't really sure of the utility or about parts of the design (like the trait). Replaced |
Implements parsing and printing for the Schema Coordinates RFC.
Here,
SchemaCoordinate
is an enum of all the different kinds of coordinates. Each kind of coordinate is also its own type.The goal of this API is:
.argument()
method). Each kind of coordinate having its ownimpl
is handy for thisfn lookup(&Schema, FieldArgumentCoordinate) -> Option<Node<InputValueDefinition>>
, so the return value can be typed. I'm not 100% convinced of how important this is as you may often have just aSchemaCoordinate
, which can return multiple types.Some other options:
TypeCoordinate
could just be an alias ofNamedType
🤪SchemaCoordinate
enum without all the specific types--I like this less for how it's used in validation (different types with simple methods for pushing/popping are ideal)Type.field(arg:)
). A schema coordinate could then be pointer-sized, here it's 3 pointers + a discriminant. A downside is that you need to allocate when you append a field or argument or something.