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 47 forks source link

Bugfix/Feature: pascalCase; Bugfix: recursive nesting #9

Closed bohdanbirdie closed 4 years ago

bohdanbirdie commented 4 years ago

This PR is going to fix the issue with pascalCase error, initially committed by @keesvanlierop Also, I extended that functionality to support upper case enums as well.

The other thing that was failing for me was a recursive nesting. Check this schema

type User {
  id: Int!
  username: String!
  tasks: [Task!]!
}

type Task {
  id: Int!
  description: String
  author: User!
  status: TaskStatus!
}

so, when I create a mock of a task -> user mock will be created, but then user mock will create a task mock and this will run recursively until the stack can't hold it anymore. Overrides won't help because they come after the mock is created so I switched to the getters, so they won't create a nested mock if there is an override.

bohdanbirdie commented 4 years ago

ok, @ardeois should be good for the review 👍

ardeois commented 4 years ago

@bohdanbirdie You should be good to update your branch with master. I've updated all dependencies and added precommit hook that should run prettier for you. So it will format the README.md properly

bohdanbirdie commented 4 years ago

@ardeois ok, updated everything, synced, added test and changed to pascal case as thee default