graphile / graphile/graphile-engine
Feature Request: Expose 1 to 1 relation by rest of Composite key on object
- Dominant language
- JavaScript
- Stars
- 764
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
I'm submitting a ...
* [ ] bug report
* [x] feature request
* [ ] question
PostGraphile version: v4.4.0
Given the following SQL
```sql
CREATE TABLE languages("id" SMALLINT PRIMARY KEY);
CREATE TABLE foo("id" SMALLINT PRIMARY KEY);
CREATE TABLE foo_names
(
"foo_id" SMALLINT NOT NULL REFERENCES foo(id),
"language_id" SMALLINT NOT NULL REFERENCES languages(id),
"name" VARCHAR (16) NOT NULL UNIQUE,
PRIMARY KEY(foo_id, language_id)
);
```
I would like to be able to request resources with a composite key referencing the current object by just the other fields in the composite key.
```gql
{
# Without `pg-simplify-inflector` renames to show more clearly
allFoos {
nodes {
# Current solution
fooNamesByFooId(condition: { languageId: 1 }) {
# Will always return a list with asingle element since
# (languageId, fooId) is the key for fooNames
nodes {
name
}
}
# What I want to do here:
fooNamesByFooIdAndLanguageId(languageId: 1) {
# Returning the element directly
name
}
}
}
}
```
I could not find any way to accomplish this currently. Is this something that you would be interested in a PR/plugin for?
Contributor guide
Assessment
This issue has not been assessed yet.