Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it support circular data structure? #4

Open
tanekim88 opened this issue Sep 7, 2018 · 5 comments
Open

Does it support circular data structure? #4

tanekim88 opened this issue Sep 7, 2018 · 5 comments

Comments

@tanekim88
Copy link

tanekim88 commented Sep 7, 2018

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.

@st0ffern
Copy link
Collaborator

Try wrapping composeWithDataLoader around composeWithMongoose.

composeWithDataLoader(composeWithMongoose(TC))

@adam-bratin
Copy link

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

@Marcvander
Copy link

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');

@nodkz
Copy link
Member

nodkz commented Oct 8, 2019

@Marcvander 👍
Can you open a pull request?

@GimignanoF
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants