E
E
Erl2020-10-06 09:11:14
Vue.js
Erl, 2020-10-06 09:11:14

How to make such queries in GraphQL?

I use vue-apollo for requests, there is a request like this

spoiler

query {
  articles(sort: "created_at:desc", where: { publish = "true"}) {
    id
    title
    image {
      url
      formats
    }
    category{
      name
      url
    }
    tags {
      name
    }
    created_at
    url
  }
}


I want to make a selection by matching url category, that is, if the category link matches, then get records with this category
a request of this kind
spoiler

query {
  articles(sort: "created_at:desc", where: { category.url = "wow" }) {
    id
    title
    image {
      url
      formats
    }
    category{
      name
      url
    }
    tags {
      name
    }
    created_at
    url
  }
}


But, I can not find information on how to make such nested queries.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Erl, 2020-10-07
@NooBiToo

I'm answering my own question.
It is necessary to make a connection, let's say many to many, and choose already 1 category that contains all the articles, for example, I created a schema and make the following request

query categoryByUrl($url: String!) {
          categoryByUrl(url: $url) {
            name
            articles {
              id
              title
              content
              image {
                url
                formats
              }
            }
          }
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question