Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[dreamOle25] - Bring data to your LWC without A...

[dreamOle25] - Bring data to your LWC without Apex using the GraphQL Wire Adapter

Using Lightning Data Service is great in LWC, getting record data in just a few lines of code without having to write Apex, Test Class, be sure that Field Level Security is checked etc… But you quickly hit a limit, as soon as you want to get more specific data, applying filters or getting relationships, you need to go back to Apex. Not anymore ! With the GraphQL Wire Adapter you’ll be able to query Salesforce data right from your LWC without writing a single line of Apex. Let’s have a look !

Avatar for Fabien Taillon

Fabien Taillon

April 04, 2025
Tweet

More Decks by Fabien Taillon

Other Decks in Programming

Transcript

  1. Salesforce MVP - Hall of Fame Partner & CTO at

    Texeï Paris Developer Group leader French Touch Dreamin team https://www.linkedin.com/in/fabientaillon/ https://x.com/FabienTaillon https://www.salesforce.com/trailblazer/fabien https://www.texei.com Who am I Fabien Taillon
  2. • A query language for your API • Created by

    Facebook in 2012 • No need to call several APIs • Get many resources in a single request • Ask for what you need, get exactly that • Self documented • With a type system source: Michael Poirier-Ginter What is GraphQL
  3. • a read only stream of data • shared cache

    between components (standard & custom) • reactive to changes outside of the component’s scope • no Apex with standard Lightning Data Service Wire Adapters • just import it and use it 🎉 What is a Wire Adapter
  4. Query any list of records you want • Order them

    • Group them • … Easy to use because • you don’t need to write any Apex • respects user Field Level Security • use the same shared Lightning Data Service cache Get for a custom component • a list of all contacts for a given account • a search page • a hierarchy of records • one specific record with filters, without knowing its Id at first • … What is the GraphQL Wire Adapter
  5. An easy to use local client to test your queries

    • Get an access token ◦ for instance use sf org display • Use the following url: ◦ https://{MyDomainName}.my.salesforce.com/services/data/v{version}/gra phql • Then you can: ◦ query ◦ autocomplete ◦ look at API documentation (display existing fields, available formatting etc) https://ww.altairgraphql.dev Connect to GraphQL API Altair GraphQL Client
  6. Demo source code: https://github.com/FabienTaillon/graphql-wire-adapter-demo Developer Guide: https://developer.salesforce.com/docs/platform/graphql/guide/graphql-wire-lwc.html GraphQL Wire Adapter

    for LWC Blog Post: https://developer.salesforce.com/blogs/2023/02/now-in-pilot-graphql-wire-adapter-for-lwc GraphQL API & LWC Wire Adapter Trailblazer Community Group: https://trailhead.salesforce.com/trailblazer-community/groups/0F94S000000kRExSAM Resources