Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send graphql query with fragments in Android

I am new to graphql and I need a help to send graphql query with fragments for my android app. Below is the query format accepted by network.

query{
  user(ident:"JohnDoe"){
    myStory{
      description,
    placements(first:3){
      edges{
        node{
          mediaItemType
          mediaItem {
            ...VideoFragment
            ...PhotoFragment
          }
        }
      }
    }
    }
  }
}
fragment VideoFragment on Video {
    videoHTML
}
fragment PhotoFragment on Photo {
    url(size:10)
}

Any help appreciated!!

like image 533
Babs Avatar asked Oct 28 '25 08:10

Babs


2 Answers

This likely depends on the server implementation of GraphQL. GraphQL does not define the medium, which leaves this question as being somewhat broad. Since express-graphql is so common, I'll make a guess that you may be using that. If that's true, you can query it over HTTP with more details outlined on the documentation for that project. If that happens to not be the case, you'll need to do some more digging.

like image 57
Ryan Avatar answered Oct 30 '25 23:10

Ryan


I got it working by adding it in strings.xml as below. make sure there are NO extra spaces.

<string name="graphiql_detail_search">
{
  user(ident: "JohnDoe") {
    myStory {
      description
      placements(first: 3) {
        edges {
          node {
            mediaItemType
            mediaItem {
              ...VideoFragment
              ...PhotoFragment
            }
          }
        }
      }
    }
  }
}

fragment VideoFragment on Video {
  videoHTML
}

fragment PhotoFragment on Photo {
  url(size: 10)
}
like image 34
Babs Avatar answered Oct 31 '25 01:10

Babs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!