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

[London's Calling 2023] Bring data to your LWC ...

[London's Calling 2023] 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!

Fabien Taillon

June 09, 2023
Tweet

More Decks by Fabien Taillon

Other Decks in Programming

Transcript

  1. #LDNsCall #LC23 Bring data to your LWC without Apex using

    the GraphQL Wire Adapter Fabien Taillon https://trailblazer.me/id/fabien https://www.linkedin.com/in/fabientaillon https://twitter.com/FabienTaillon
  2. Who am I Fabien Taillon - 8x Salesforce MVP -

    CTO at Texeï - Paris Developer Group leader - French Touch Dreamin team - Serial speaker @FabienTaillon https://texei.com/blog
  3. - 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 A query language for your API What is GraphQL source: Michael Poirier-Ginter
  4. - 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
  5. 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
  6. 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}/graphql - Then you can: - query - autocomplete - look at API documentation (display existing fields, available formatting etc) https://ww.altairgraphql.dev Altair GraphQL Client Connect to GraphQL API
  7. - Backward pagination - Filter with no value - Actually

    more GraphQL than Salesforce “issue” - No mutation (on the roadmap) What’s not available (yet ?)
  8. 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