Skip to main content Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.
Group

GraphQL API & LWC Wire Adapter

This group will be used to facilitate the communication between the Salesforce team and the Trailblazers using GraphQL. Feel free to share your feature requests and use cases.
Pinned

📣 Exciting Announcement! 🎉

 

Introducing the Salesforce GraphQL API and LWC Wire Adapter Trailblazer Community Group! 🚀

We are thrilled to announce the launch of our brand new community group dedicated to exploring the power of the Salesforce GraphQL API and Lightning Web Components (LWC) GraphQL Wire Adapter. This is an incredible opportunity for Salesforce developers and enthusiasts to come together, share knowledge, and learn from each other about these cutting-edge technologies.

 

🔗 What is the Salesforce GraphQL API?

The Salesforce GraphQL API is a powerful data query and manipulation language that provides a flexible and efficient approach to fetching data from your Salesforce org. It enables you to precisely request only the data you need, reducing network overhead and improving performance. With the GraphQL API, you can now access Salesforce data in a more intuitive and personalized manner. Get started today!

 

🔗 What are Lightning Web Components (LWC) and the Wire Adapter?

Lightning Web Components (LWC) is a modern framework that empowers developers to build efficient, reusable, and responsive web components on the Salesforce platform. These components can be used to create rich user interfaces and seamless experiences. The LWC Wire Adapter simplifies data integration by providing a declarative way to fetch and update data from Salesforce without the need for complex Apex code. Get started today!

 

👥 Who is this community group for?

This Trailblazer Community Group is for developers, admins, and Salesforce enthusiasts who are eager to explore the Salesforce GraphQL API and harness the power of our GraphQL Wire Adapter for LWC. Whether you are a beginner or an experienced developer, this group is the perfect platform for you to engage, learn, and share your expertise with like-minded individuals.

 

💡 What can you expect from this community group?

By joining this group, you will gain access to a vibrant community of experts and peers who are passionate about Salesforce development. Here's what you can expect:

1. Knowledge Sharing: Learn from experienced developers and thought leaders who will share best practices, tips, and tricks to leverage the Salesforce GraphQL API and GraphQL Wire Adapter effectively.

2. Q&A: Engage in lively discussions, ask questions, and get answers from community members and Salesforce experts who are actively working with the GraphQL API and GraphQL Wire Adapter.

 

📢 Join Us Today!

Don't miss out on this incredible opportunity to explore the Salesforce GraphQL API and LWC Wire Adapter. Join the Salesforce GraphQL API and LWC Wire Adapter Trailblazer Community Group today, and let's unlock the potential of these game-changing technologies together!

#GraphQL #Lightning Web Components

0/9000

I've activated Experience Delivery Beta on a new Experience Site in a Spring 25 sandbox, but I am unable to publish my site when it contains LWCs with GraphQL wire adapters. I've narrowed the site down to a single component, and all the ones I test that inhibit publishing contain GraphQL adapters. It throws an error as below.

mcontent.management.api.deployment.exception.MCDeploymentException: Error with deployment hook: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to get calculate module size for salesforceLds/c__teamListBuild: Post: mcontent.management.impl.deployment.ManagedContentSitesSupportObserver

Is it reasonable to conclude that Experience Delivery Beta doesn't support GraphQL?

2 answers
0/9000

So found a error with using graphQL in LWC, that works fine when done via the graphQL API directly. 

 

We have an object Purchase_Order__c which has a master detail to Case, and another lookup to Case for when the case is transitioned to a new to a new type of case. 

 

When trying to do a graphQL query for those related lists of the Case, it results in an error:

{"errorType":"adapterError","error":[{"extensions":{"ErrorType":"ValidationError"},"locations":[{"column":15,"line":61}],"message":"Validation error of type FieldUndefined: Field 'value' in type 'Purchase_Order__cConnection' is undefined @ 'uiapi/query/Case/edges/node/Purchase_Orders__r/value'","paths":[]},{"extensions":{"ErrorType":"ValidationError"},"locations":[{"column":15,"line":62}],"message":"Validation error of type FieldUndefined: Field 'displayValue' in type 'Purchase_Order__cConnection' is undefined @ 'uiapi/query/Case/edges/node/Purchase_Orders__r/displayValue'","paths":[]}]}

When doing the same query on the graphql api (/services/data/v62.0/graphql) it works as expected. 

 

I have case open with Salesforce.

2 answers
  1. Jan 28, 9:26 PM

    Hi Sunny, 

     

    I have worked it out this morning after commenting out part of my where clause, it seems that the graphql api allows 

     

    { Payment_Date__c: { ne: null }}

    Where as the LWC does not allow this, and requires the proper DateInput - https://developer.salesforce.com/docs/platform/graphql/guide/filter-fields.html?q=date#:~:text=particular%20Date.-,DateInput,-input%20DateInput%20%7B

     

     

    { Paid_Date__c: { ne: {value:null } }}

     

    Not sure how many times the DateInput format has tripped me up now. 

     

    Cheers 

    Tony 

     

0/9000
1 answer
  1. Sep 9, 2024, 1:28 PM

    Hi @Manas Behera,

    Lightning Web Components (LWC) do support GraphQL queries. 

    You may find the following resources helpful for implementing and configuring GraphQL queries within an LWC component: 

    1. GraphQL Wire Adapter for LWC: Provides basic capabilities and setup for using GraphQL with LWC.
    2. graphql: Get detailed information on how to use GraphQL in LWC, including how to structure your queries.
    3. Query Your Data: Understand how to perform GraphQL queries in LWC, including examples and syntax.
    4. GraphQL Wire Adapter Best Practices : Explore best practices for using GraphQL with LWC to ensure optimal performance and maintainability.

    Additional reference:

    https://trailhead.salesforce.com/trailblazer-community/users/0054S000001OHhAQAW/feed?tab=answers 

     

    I hope this helps you. Thanks!

0/9000

Hello,

 

I have a case open with support about this error I am seeing trying to do a aggregate query using graphQL grouping on a custom date field:

 

For full details see my post on stack exchange:

https://salesforce.stackexchange.com/questions/428193/issues-with-salesforce-graphql-and-date-fields#:~:text=Issue%202%3A%20Grouping%20by%20custom%20Date%20fields%20results%20in%20an%20error

 

@Benjamin Sklar are you aware if this is supported or not?

If it is not the error message is rubbish.

 

Thanks

Tony

1 answer
0/9000

Hello everyone, 

 

 I have only used Lightning Data Service and Apex in the past when I needed to retrieve data. I'm considering using GraphQL for an upcoming use case, but I'm unsure what are the pros and cons of using Apex vs. GraphQL. I haven't been able to find a good comparison of each approach. Could anyone provide some examples of considerations when deciding between using Apex and GraphQL? Thank you!

2 answers
  1. Jan 15, 12:29 AM

    As a Dev, on top of what Kirsten listed

    Pros for GraphQL:

    • No Apex Test coverage
    • No Apex class to provide permissions for
    • Object and field permissions require read access min

    Cons for GraphQL:

    • Missing object/field access can cause errors that are harder to handle gracefully or override
0/9000

I´m trying to retrieve data from a __mdt object using "first: 30" as param in the query but it doesn't work (I never receive a response). Without it, I get 10 items as expected. Is this a bug or a limitation?. Thanks

2 answers
0/9000

As per the latest documentation, the `graphql` wire adapter is not supported in Experience Cloud sites. However, I have tried it in my developer edition org, in Aura Experience Cloud sites and it works absolutely fine. Only in LWR Experience Cloud sites, the import does not work and routes to the error page regardless of LWS enabled or not. Is this an undocumented behavior? Can we safely test and use `graphql` in sandbox and production Aura sites?

2 answers
0/9000

I'm new to GraphQL and attempting to migrate from SOQL. My working query is quite simple: Get accounts and their respective owners (simplifying here):

SELECT Name, Owner.FederationIdentifier, FROM Account WHERE Id IN ('123',456')

How do I translate that to GraphQL?

The below query works, but how do I get the Owner?:

query accounts {

        uiapi {

          query {

            Account(where: {

              or: [ { Id: {eq: "123" } }, { Id: {eq: "456" } } ]  

            }) {

              edges { node { Name { value } } } 

            } 

          } 

        } 

      }

3 answers
0/9000

Hello 

I am currently working within a managed package and facing a specific challenge with GraphQL in Salesforce. Our project involves referencing Field Service objects in our GraphQL queries. According to the Salesforce GraphQL documentation, it seems impossible to pass fields and objects in a GraphQL query dynamically.

 

The primary issue we are encountering is the need to hardcode fields in our GraphQL queries, which is causing deployment difficulties in our managed package environment. This has been a significant hurdle in our development process.

 

Does anyone in the community have experience with this or know of any alternative methods or workarounds to be able to pass fields and objects to graphql query?

 

 Additionally, are there any updates or planned enhancements in Salesforce's roadmap that might address this issue?

 

Any insights, suggestions, or shared experiences would be incredibly valuable to us. Thank you in advance for your time and support!

 

cc @Kevan Moothien

2 answers
  1. Jul 18, 2024, 4:54 PM

    Just tried hard-coding as well.  No joy.

0/9000

Hello, 

We have static data on the Salesforce platform and planning to create reusable LWC component using GraphQL which can be reused by other product. So, other product team will import the reusable component, pass the key and grab the data to be display on their component. However, we are not able to do that because of export with @wire adapter. We tried with @api method as well but did not work. Is this can be possible? Any example would help

0/9000