Closed goto-bus-stop closed 10 months ago
Oh hmm, a FieldCoordinate
can also refer to an enum value. The RFC actually calls it a type attribute rather than a field: https://github.com/graphql/graphql-wg/blob/main/rfcs/SchemaCoordinates.md#typeattribute
So you can have Query.products
referring to a field and ProductType.book
referring to an enum value. that makes the typed lookup by coordinate idea a bit less interesting.
I think for pointing out a specific implements
, or pointing out a directive application, we would use both a coordinate + a string (or another coordinate) for the more specific thing in the error message. It does mean that the coordinates for error locations would often be a parent node of where the error actually occurred, but it's not gonna be super far away...
For example, if you do something like
type Example {
name @deprecated(reason: false)
}
you could get an error with its location at coordinate Example.name
, and the message formatting using two coordinates:
Expected type String, but Boolean was provided to `@deprecated(reason:)` on `Example.name`
(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.
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 coordinate: String
uses in diagnostics with either a specific coordinate type or SchemaCoordinate
.
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.