GraphQL ObjectType with dynamic fields based on arguments

后端 未结 2 664
情书的邮戳
情书的邮戳 2021-01-07 21:35

We are in the situation that the response of our GraphQL Query has to return some dynamic properties of an object. In our case we are not able to predefine all possible prop

2条回答
  •  长发绾君心
    2021-01-07 22:26

    One more possible solution could be to declare any such dynamic object as a string. And then pass a stringified version of the object as value to that object from your resolver functions. And then eventually you can parse that string to JSON again to make it again an object on the client side.

    I'm not sure if its recommended way or not but I tried to make it work with this approach and it did work smoothly, so I'm sharing it here.

提交回复
热议问题