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

Infinite recursiveness #60

Open
zvictor opened this issue Aug 17, 2022 · 1 comment
Open

Infinite recursiveness #60

zvictor opened this issue Aug 17, 2022 · 1 comment

Comments

@zvictor
Copy link
Contributor

zvictor commented Aug 17, 2022

Gql-generator goes into infinite recursiveness once we add just 2 lines of code to the end of example/sampleTypeDef.graphql!
CC @RvanderLaan

Steps to reproduce:

  1. Copy the code below to example/sampleTypeDef.graphql:
type Query {
    user(id: Int!): User!
    members: [Member!] @deprecated(reason: "Test a deprecated query")
}

type Mutation {
    signup(
        email: String!
        username: String!
        password: String!
    ): UserToken!

    signin(
        email: String!
        password: String!
    ): String!

    setConfig(
        prefs: PrefsInput
    ): Config!

    sendMessage(
        message: String!
    ): String! @deprecated(reason: "Test a deprecated mutation")
}

input PrefsInput {
    language: String!
}

type Config {
    language: String!
    level(domain: String!): Int!
    lastSeen(domain: String!): Int!
    theme(domain: String!): Int!
}

type Subscription {
    UserUpdated(UserId: Int!): User
}

type UserToken {
    token: String!
    user: User!
}

type User {
    id: Int!
    username: String!
    email: String!
    createdAt: String!
    context: Context!
    details: UserDetails!
    address: String! @deprecated(reason: "Test a deprecated field")
}

union UserDetails = Guest | Member | Premium

type Guest {
    region(language: String): String!
}

type Member {
    address: String!
}

type Premium {
    location: String!
    card: Card!
}

type Card {
    number: String!
    type: [CardType!]!
    owner: User! # <------------------ ADDED ---------------------
}

type CardType {
    key: String!
}

type Context {
    user: User! # Circular ref
    domain: String!
    card: Card! # <------------------ ADDED ---------------------
}
  1. Run the tests or just node index.js --schemaFilePath ./example/sampleTypeDef.graphql --destDirPath ./example/output
@zvictor
Copy link
Contributor Author

zvictor commented Aug 17, 2022

I think I solved it! 🎉
@timqian please decide on #59 so that I can base the solution for this issue on that refactoring or not.
Once #59 is merged I will push the fix for this one 😊

zvictor added a commit to zvictor/gql-generator that referenced this issue Aug 17, 2022
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

1 participant