Closed robdodson closed 3 years ago
:wave: @robdodson, very good question. We do plan to support edges and nodes in the GraphQL query @jeffsee55 could tell you more about it.
On a side note, I'm very curious how you can leverage Tina Content API with Eleventy 👀
We only support the "belongs_to" path at the moment, and will likely not support the "has_many" portion until we implement a more robust indexing service. It's a priority for us but will be a big chunk of work so it's not likely to land soon. Having said that, we're going to future-proof the API by changing the result of list
queries. So even getPostList
will have edges:
query {
getPostList {
edges {
node {
data {
... on Article_Doc_Data {
title
}
}
}
}
}
}
}
On a side note, I'm very curious how you can leverage Tina Content API with Eleventy 👀
As our site has grown, we've had to build a sort of ad hoc data layer using a combination of Eleventy's _data
directory and .11tydata.js
files. As an example, for https://web.dev/authors/ we have to loop through every post on the site, and for each post add it to an authors dictionary, and then return that dictionary in a way that eleventy can paginate. I'd much prefer using a standard query language to get that data.
My thinking was that in dev, and when we do our production build, we could fire up the local tina graphql server, and have our queries in the eleventy _data
directory.
We only support the "belongs_to" path at the moment, and will likely not support the "has_many" portion until we implement a more robust indexing service.
OK, so if I'm understanding correctly, that means that for now you can query if an article or author belongs to a collection, but you can't query all of the author's relationships back to the articles, correct?
That's right, @robdodson. What you've done in your first query is the only thing we support at the moment. We'll get there, though!
I'm a total GraphQL novice, so apologies in advance if this is a silly question 😅
I'm experimenting with using tina-graphql-gateway-cli and eleventy. Following the CLI docs, I was able to create a simple query to list all of my posts, including their authors.
But I was curious if there was a way to query all of my authors, and list every post associated with them? roughly something like this:
I guess since the schema defines a relationship type, I was imagining I could traverse it in both directions. But maybe I'm thinking about it wrong?