7.1. GraphQL schema should be "hairy" - how to avoid circular references? #124
-
Based on this rule, I modeled a type called type User {
id: ID!
fullName: String!
avatarUrl: String!
homeTown: String!
friends: [User!]!
} However when I tried to mock a response using MSW, I got this error:
How to avoid circular references while still making the schema hairy? I can only think about typing friends to be something like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is rather complicated TBH. But you should build static manual responses using plain js objects to make sure they have finite depth. And better do that statically without referring to classes or object references that, I assume MSW serialiser tries to follow references all the way to the end that never happens as it's circular and non-serialisable. A real query will have a finite depth, and so is the response. |
Beta Was this translation helpful? Give feedback.
This is rather complicated TBH. But you should build static manual responses using plain js objects to make sure they have finite depth. And better do that statically without referring to classes or object references that, I assume MSW serialiser tries to follow references all the way to the end that never happens as it's circular and non-serialisable.
A real query will have a finite depth, and so is the response.