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

How can i use fragments recursively? #34

Closed
jonywtf opened this issue Feb 16, 2017 · 2 comments
Closed

How can i use fragments recursively? #34

jonywtf opened this issue Feb 16, 2017 · 2 comments

Comments

@jonywtf
Copy link

jonywtf commented Feb 16, 2017

Hi! I want to use fragment recurcively...

    export const folderFragment = client.createFragment(`
        fragment on Folder {
            id
            name
            description
            shortdescription
            image
            folders {
                ...${folderFragment}
            }
        }
    `);
    client.query(`{
        folders {
            ...${folderFragment}
        }
    }`);

but i get an error

error Error: There is no such fragment: undefined

Help me please..Thank you!

@jonywtf
Copy link
Author

jonywtf commented Feb 16, 2017

little hack with

    gql._fragments.folderFragment = gql._fragments[folderFragment];
   ...${folderFragment} -> ...folderFragment

doesn't work. I get an error:

error RangeError: Maximum call stack size exceeded

but i can run query in graphiql gui on Golang GraphQL server (https://github.com/neelance/graphql-go/) with no errors

fragment folderFragment on Folder {
  id
  name
  description
  shortdescription
  image
  folders {
    ...folderFragment
  }
}
query {
  folders {
    ...folderFragment
  }
}

@jonywtf
Copy link
Author

jonywtf commented Feb 16, 2017

Please, check my pull request #35

@jonywtf jonywtf closed this as completed Feb 16, 2017
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