graphql-compose-dataloader
graphql-compose-dataloader copied to clipboard
Does it support circular data structure?
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.
Try wrapping composeWithDataLoader around composeWithMongoose.
composeWithDataLoader(composeWithMongoose(TC))
+1 I am also seeing this issue. I have tried composeWithDataLoader(composeWithMongoose(TC)) but it still throws the error
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 👍 Can you open a pull request?
November 2019, this still happens. Doing the json-stringify-safe trick works, but of course is not the preferred solution... Any signs on this?