I'm trying to implementing simple search functionality using GraphQL wire adapter in LWC.
But when I'm using this component in Offline Mobile App GraphQL is returning nothing..!!!
When same component is used in Online Mobile App then it's working fine..
Records are already synced and user is able to view record also.
import { LightningElement,wire,track } from 'lwc';
import { gql, graphql } from "lightning/uiGraphQLApi";
export default class Offline_searchLead extends LightningElement {
errors;
@track keyword = '';
@wire(graphql, {
query: '$myQuery',
variables: '$variables'
})
graphqlQueryResult({ data, errors }) {
if (data){
alert('data : '+JSON.stringify(data));
}else if(errors){
alert('something happened');
this.errors = errors;
}
}
get myQuery() {
return gql`
query searchLeads($keyword: String) {
uiapi {
queryLead:query{
Lead(
where:{
or: [
{ Name: { like: $keyword } }
]
}
,
first: 10
) {
edges {
node {
Id
LastName{
value
}
Status{
value
}
CreatedDate{
value
}
LeadSource{
value
}
}
}
}
}
}
}`;
}
get variables() {
return {
keyword:'%'+this.keyword+'%'
};
}
handleSearch(event){
this.keyword = event.detail.value;
}
}
Also GraphQL is returning data when no variables are used. Can anyone help me with this........ I need to implement lots of functionality which depends on variables..