graphql 突变没有 [=10th=] 嵌套字段

graphql mutation dosen't return nesetd fields

如何在保留类型名称的同时 return 来自突变的嵌套字段

我在后端使用 prismagraphql-yoga

async createComment(parent, args, ctx, info) {
    console.log(args);
    const comment = await ctx.db.mutation.createComment(
      {
        data: {
          ...args,
          user: {
            connect: {
              id: ctx.request.userId
            }
          },
          item: {
            connect: {
              id: args.itemId
            }
          }
        }
      },
      info
    );

    console.log(comment);

    ctx.pubsub.publish('PUBSUB_NEW_COMMENT', { newComment: comment });

    return comment;
 }

突变响应发送 return 在我的案例中 useritem 的嵌套字段是 null

我确实通过将 itemuser 字段添加到客户端 gql 突变中解决了这个问题

const COMMENT_MUTATION = gql`
  mutation COMMENT_MUTATION($text: String, $itemId: String) {
    createComment(text: $text, itemId: $itemId) {
      id
      text
      user { // adding user field here
        id
        name
      }
      item { adding item field here
        id
        title
        user {
          id
          name
        }
      }
    }
  }
`;

我不明白这是怎么发生的,但因为它也影响了服务器上的订阅负载 基本上从 gql 突变中添加或删除字段也会改变订阅的有效负载