Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created January 13, 2023 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/6f0a5f18d9bd9bfca4e1c30b64932960 to your computer and use it in GitHub Desktop.
Save arun12209/6f0a5f18d9bd9bfca4e1c30b64932960 to your computer and use it in GitHub Desktop.
import { LightningElement, wire } from 'lwc';
import { gql, graphql } from 'lightning/uiGraphQLApi';
export default class AccountsGQL extends LightningElement {
records;
errors;
minAmount = '1000000’;
@wire(graphql, {
query: gql`
query myOperationName($minAmount: Currency) {
uiapi {
query {
Account(where: { AnnualRevenue: { gte: $minAmount } }) @category(name: "recordQuery") {
edges {
node {
Id
Name @category(name: "StringValue") {
value
}
AnnualRevenue @category(name: "CurrencyValue") {
displayValue
}
}
}
}
}
}
}`,
variables: '$myVariables',
operationName: 'myOperationName',
})
graphqlQueryResult({ errors, data }) {
if (data) {
this.records = data.uiapi.query.Account.edges.map(edge => edge.node);
this.errors = undefined;
} else if (errors) {
this.errors = errors;
}
}
get myVariables() {
return {
minAmount: this.minAmount
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment