graphql-compose-dataloader icon indicating copy to clipboard operation
graphql-compose-dataloader copied to clipboard

Does it support circular data structure?

Open tanekim88 opened this issue 7 years ago • 5 comments

Suppose Teacher mongoose model has students list, but each student can be teacher of anyone, including the current teacher. If I use composeWithMongoose and composeWithDataLoader, and create one teacher and search for one teacher using getResolver("findOne"), it is throwing error, citing JSON.stringify does not support circular structure. If I do not use composeWithDataLoader, circular structure is working and is supported.

tanekim88 avatar Sep 07 '18 17:09 tanekim88

Try wrapping composeWithDataLoader around composeWithMongoose.

composeWithDataLoader(composeWithMongoose(TC))

st0ffern avatar Sep 12 '18 06:09 st0ffern

+1 I am also seeing this issue. I have tried composeWithDataLoader(composeWithMongoose(TC)) but it still throws the error

adam-bratin avatar Jul 04 '19 23:07 adam-bratin

I had the same issue and I solved it this way: I installed this module (https://github.com/moll/json-stringify-safe) by running : npm install --save json-stringify-safe Then in node_modules/graphql-compose-dataloader/lib/composeWithDataLoader.js, I changed at line 3 : var _stringify = require('babel-runtime/core-js/json/stringify'); by : var _stringify = require('json-stringify-safe');

Marcvander avatar Oct 07 '19 14:10 Marcvander

@Marcvander 👍 Can you open a pull request?

nodkz avatar Oct 08 '19 08:10 nodkz

November 2019, this still happens. Doing the json-stringify-safe trick works, but of course is not the preferred solution... Any signs on this?

GimignanoF avatar Nov 07 '19 16:11 GimignanoF