Use of the lightning/uiGraphQLApi module
Why is this an issue?
The lightning/uiGraphQLApi module is being superseded by a newer lightning/graphql GraphQL API that supports more features including dynamic queries.
Examples
Example of incorrect code:
import { gql, graphql } from 'lightning/uiGraphQLApi';
export default class AccountList extends LightningElement {
@wire(graphql, {
query: gql`
query AccountQuery {
uiapi {
query {
Account(first: 10) {
edges {
node {
Name { value }
}
}
}
}
}
}
`
})
accounts;
}
Example of correct code:
import { gql, graphql } from 'lightning/graphql';
export default class AccountList extends LightningElement {
@api recordLimit = 10;
@wire(graphql, {
query: gql`
query AccountQuery($limit: Int) {
uiapi {
query {
Account(first: $limit) {
edges {
node {
Name { value }
}
}
}
}
}
}
`,
variables: '$queryVariables'
})
accounts;
get queryVariables() {
return { limit: this.recordLimit };
}
}
How can I fix violations?
Update imports: Change from
lightning/uiGraphQLApitolightning/graphql.Review queries: Take advantage of new features like dynamic queries.
Update variables handling: Use the new patterns for passing variables.
When should I disable this rule?
The old API is still supported, so you can disable this rule if you are not planning to upgrade.
Resources
