Apollo/GraphQL 请求 ID 时无法获取引用的实体

Apollo/GraphQL not able to get referenced entities when asking for the ID

堆栈:

我面临的问题是,当我使用 Apollo 执行我的 GraphQL 查询时,有一个引用实体的集合,抓取所有字段 除了 id 工作正常,但只要我添加

id {
   entityId
   organisationId
}

为了同时获取 id 字段,它 return 是所有相同实体的集合。

假设有三个用户:John、Jane 和 Jen;具体按照这个顺序。当我执行查询时,它将 return John 的对象三次,id 在 GraphQL 查询中时 。如果 GraphQL 查询中的 id 不是 ,它将正确 return 所有实体。

当我通过 Postman 执行查询时,它工作正常。这似乎是 Apollo 特有的问题。

id实体:

public class TradelyId implements Serializable {
    String entityId;
    String organisationId;
}

一些可能有助于描绘画面的片段:

@Document
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
public class Assignment implements Serializable {

    private static final long serialVersionUID = -165856150537588143L;

    @Id
    @NotNull
    @NonNull
    @EqualsAndHashCode.Include
    private TradelyId id;

    @NotNull
    @NonNull
    private Instant startDateTime;

    @NotNull
    @NonNull
    private Instant endDateTime;

    @NotNull
    @NonNull
    @DBRef
    @ShallowReference
    private Job job;

    @NotNull
    @NonNull
    @DBRef(lazy = true)
    @ShallowReference
    private List<User> users = new ArrayList<>();

}
type Assignment {
    id: TradelyId!
    startDateTime: String!
    endDateTime: String!
    job: Job!
    users: [User!]!
}

input AssignmentRefInput {
    id: TradelyIdQueryInput!
}

input AssignmentCreateInput {
    id: TradelyIdCreateInput!
    startDateTime: String!
    endDateTime: String!
    job: JobRefInput!
    users: [UserRefInput!]!
}

input AssignmentUpdateInput {
    id: TradelyIdQueryInput!
    startDateTime: String!
    endDateTime: String!
    job: JobRefInput!
    users: [UserRefInput!]!
}

extend type Mutation {
    createAssignment(assignment: AssignmentCreateInput!): TradelyId!
    updateAssignment(assignment: AssignmentUpdateInput!): TradelyId!
}

extend type Query {
    assignment(id: TradelyIdQueryInput!): Assignment
    assignments(id: String!): [Assignment!]!
    assignmentForJobId(id: TradelyIdQueryInput!): Assignment
    usersAvailableForAssignment(startDateTime: String!, endDateTime: String!): [User!]!
    assignmentsForUser: [Assignment!]!
}

从缓存中删除 typename 似乎有效。

const cache = new InMemoryCache({
  addTypename: false,
});

const apolloClient = new ApolloClient({
  uri: '',
  cache: cache,
});