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 to query nested arrays? #493

Open
jkhaui opened this issue Nov 18, 2018 · 0 comments
Open

How to query nested arrays? #493

jkhaui opened this issue Nov 18, 2018 · 0 comments

Comments

@jkhaui
Copy link

jkhaui commented Nov 18, 2018

This isn't so much an issue, but I've searched everywhere and can't really find an answer specific to my problem with nested queries using the Apollo boilerplate.

I'm using the basic boilerplate and have modified FeedPage.js and its associated query to fit my own GraphQL server. It works great for the most part; except when I try to query an array nested within a parent array. For example, consider this query:

query {
posts {
nodes {
id
content
comments {
nodes {
id
content
}
}
}
}
}

Now, the following code works:

        <Fragment>
          <h1>Feed</h1>
          {data.posts &&
            data.posts.nodes.map(post => (
              <Post
                key={post.id}
                post={post}
                refresh={() => refetch()}
              />
            ))}
          {this.props.children}
        </Fragment>

But my issue is: what if I want to return comment.content, and map a list of comments to keys?

I'm really stuck here and would greatly appreciate some guidance. Thanks!

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