Y
Y
Yourmind2019-12-19 18:12:40
Java
Yourmind, 2019-12-19 18:12:40

How to write a Graphql query correctly in my case?

Good day!
i have a little problem with graphql query
if i have public List AdvertisementsByFiltersearch(Filter filter) method on backend
where filter:
public Filter(boolean usefilter, Integer Topprice, Integer Lowprice, SortingPrinciple SortingPrincipl, String Name, Set Idtags){
this.usefilter= usefilter;
this.topprice=topprice;
this.sortingprinciple=SortingPrinciple;
this.lowerprice=Lowprice;
this.idtags=Idtags;
this.name=Name;
}
public enum SortingPrinciple {
popularity,
price,
age
}
then how can I write some kind of request to this method?
photo in Alteir GRAphql client
5dfb93029ae35134659938.jpeg
5dfb930ed2ddf122629035.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Lanets, 2019-12-23
@Fi1osof

The mere presence of a method does not give you the right to call it through GraphQL queries. What and how can be requested - the scheme answers. Actually, you can see the diagram on the screenshots. filter is a named object. In requests, parameters are passed in the following form:

query {
  someQuery(
    argName: argValue,
    ...
  ){
     ....fields
  }
}

Cannot be called as a function like filter(...args)
In your case like this:
query {
  advertisementsByFiltersearch(
    filter: {
      name: "Name"
      usefilter: true
      lowerprice: 300
    }
  ){
     ....fields
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question