-
-
Notifications
You must be signed in to change notification settings - Fork 794
Closed
Milestone
Description
Is your feature request related to a problem? Please describe.
Currently AnyType
accepts any JSON value, for some cases I need to restrict AnyType
to accept only specific shape of the JSON. For example, GeoJSON specification says that a geo point is a JSON object with 2 properties type
and coordinates
This is atomic thing, so I don't want to define it as a separate GraphQL type and instead I see it as a ScalarType (I can't display information on map having only coordinates
or only type
it just doesn't make sense for me).
Describe the solution you'd like
I see 2 ways to achieve this.
- Allow to extend
AnyType
and restrict it but then it breaks Liskov substitution principle and it's not good - Allow to conifgure
AnyType
. In this case, it'd be good to have a factory function forAnyType
:
class GeoJSONPoint {
public string Type;
public double[] Coordinates;
}
AnyType.Create<GeoJSONPoint>()
// or
AnyType.create(json => isValidGeoJSONPoint(json))
Metadata
Metadata
Assignees
Labels
No labels