GraphQL circular dependency JSON

GraphQL circular dependency JSON


-1

I am trying to pass an input object to a GraphQL object that looks like this:

input User {
    id: ID
    posts: [Post]
}
input Post {
    id: ID
    user: User
}

When pass an input object of type User which has a circular dependency with Post, I get a circular dependency error in the JSON.stringify call made during the fetch:

Converting circular structure to JSON
        --> starting at object with constructor 'User'
        |     property 'post' -> object with constructor 'Array'
        |     index 0 -> object with constructor 'Post'
        --- property 'user' closes the circle"

This issue is discussed here:

GraphQL circular dependency

The answer talks about changing the schema to use extend. However extend won’t work with input types. Is there another solution?


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *