ardeois / graphql-codegen-typescript-mock-data

[GraphQL Codegen Plugin](https://github.com/dotansimha/graphql-code-generator) for building mock data based on the schema.
MIT License
132 stars 47 forks source link

fix: relationshipsToOmit bug when terminateCircularRelationships is true #77

Closed Jonghakseo closed 2 years ago

Jonghakseo commented 2 years ago
export type A = {
    B: B;
    C: C;
};
export type B = {
    A: A;
};
export type C = {
    aCollection: A[];
};

export type D = {
    A: A;
    B: B;
};

In this situation, Type B in Type D should return object A once, not an empty object.

But now, in the process of creating type D, Type A is created first, and after calling Type B inside Type A, Type B inside Type D is recognized as the second call.

This appears to be a side effect, not the originally intended recursion prevention effect, in my opinion.

So I modified the recursive call prevention logic by converting the set object to an array with immutability.

@ardeois This library is very useful for testing in my project and I want this fix to be implemented quickly. thank you 👍🏼