4

我正在尝试根据一对多关系过滤我的结果,并在postgraphile-plugin-connection-filter的文档中概述了如何做到这一点。我已启用此功能,但选项未显示。

我已重置服务器以确保已获取最新版本,但仍然不走运。

简而言之,连接过滤器关系根本不起作用。如果是,我会看到选项在此处输入图像描述

配置

postgraphile(process.env.DATABASE_URL || dbUrl, 'public', {
  appendPlugins: [ConnectionFilterPlugin],
  connectionFilterRelations: true,
  watchPg: true,
  graphiql: true,
  connectionFilterAllowNullInput: true,
  connectionFilterAllowEmptyObjectInput: true,
  enhanceGraphiql: true,
  enableQueryBatching: true,
})

##询问

query ($firstname: String) {
  allArtists(filter: {firstname: {likeInsensitive: $firstname}, awardsByArtistIdExists: true }) {
    edges {
      node {
        artistId
        firstname
        nationality

错误

{
  "errors": [
    {
      "message": "Field \"awardsByArtistIdExists\" is not defined by type \"ArtistFilter\".",
      "locations": [
        {
          "line": 2,
          "column": 65
        }
      ]
    }
  ]
}

这是过滤器 在此处输入图像描述

4

1 回答 1

0

文档说:

*Exist Boolean 字段可用于过滤相关记录的存在

但是您使用Exists的是Exist. 所以这应该可以解决问题:

allArtists(filter: {firstname: {likeInsensitive: $firstname}, awardsByArtistIdExist: true })
于 2021-10-23T23:46:42.573 回答