ardeois / graphql-codegen-typescript-mock-data

[GraphQL Codegen Plugin](https://github.com/dotansimha/graphql-code-generator) for building mock data based on the schema.
MIT License
134 stars 46 forks source link

Max stack trace error #13

Closed molandim closed 4 years ago

molandim commented 4 years ago

On my schema I have a recursive property.

// simplified object for clarity 
type Experience {
  name: String!
  similarExperiences: [Experience!]!
}

The mock is generating errors since it doesn't control this function execution.

ardeois commented 4 years ago

Yes, this is a know behaviour that I'm not sure how to fix.

An alternative would be to define an override for similarExperiences like this:

anExperience({
   similarExperiences: []
})
molandim commented 4 years ago

One approach was to have a second parameter in all functions to disable recursive invocations.

ardeois commented 4 years ago

But we would have to detect if we are creating recursive invocations or not. Feel free to create a pull request if you have ideas

ford-outreach commented 4 years ago

I ran into this issue and have opened a pull request with a possible solution. Please let me know if this approach seems reasonable. I believe it would solve my use case. https://github.com/ardeois/graphql-codegen-typescript-mock-data/pull/31