Feature Request: Expose 1 to 1 relation by rest of Composite key on object

未关闭
#670 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, sql
领域
api, backend, database

调研方向

从 issue 中的 SQL 模式和当前 GraphQL 查询开始,将返回列表的关系与所请求的单数关系进行比较。调查 PostGraphile 如何公开复合键关系,并确定是否可以无歧义地生成所需字段。当可以使用剩余的键字段直接查询复合键关系并返回相关对象时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

enhancement

I'm submitting a ...

  • bug report
  • feature request
  • question

PostGraphile version: v4.4.0

Given the following 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.

{
  # 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?

主要语言
JavaScript
星标
764
派生
128
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

graphile/graphile-engine 的其他 Issue

查看 graphile/graphile-engine 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。