graphile / graphile/crystal

Expose discrete range types as their canonicalized value, omitting `inclusive`

Open
#2,272 6 comments 0 reactions 1 assignee Claimed by @the-sun-will-rise-tomorrow View on GitHub
💅 enhancement
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

### Feature description

Currently, discrete range types such as `daterange` are represented as:

```graphql
type DateRange {
start: DateRangeBound
end: DateRangeBound
}

type DateRangeBound {
value: Date!
inclusive: Bool!
}
```

For discrete range types, we can convert them to their [canonical representation](https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-DISCRETE), so that the start of the range is always inclusive and the end always exclusive. Then, we can simplify the representation to just

```graphql
type DateRange {
start: Date # always inclusive
end: Date # always exclusive
}
```

### Motivating example

We have a lot of date ranges in our schema, and would prefer to avoid pushing the requirement to deal with the `inclusive` flag to clients.

### Breaking changes

Yes, this would be a breaking change and should probably be optional (maybe using a smart tag).

### Supporting development

I [tick all that apply]:

- [ ] am interested in building this feature myself
- [X] am interested in collaborating on building this feature
- [X] am willing to help testing this feature before it's released
- [X] am willing to write a test-driven test suite for this feature (before it exists)
- [ ] am a [Graphile sponsor](https://www.graphile.org/sponsor/) ❤️
- [ ] have an active [support or consultancy contract](https://www.graphile.org/support/) with Graphile

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.