How to create GraphQL to retrieve data using a data resource in UI Builder

gjz
Mega Sage

I am really stuck on this and could use some basic, step by step instructions.

 

I'm trying to learn how GraphQL works within UI Builder.  I've spent a considerable amount of time trying to learn GraphQL - but I really can't find any basic steps for UI Builder that are recent enough that use a current version of UI Builder.  I have found a few that are 4 - 5 years old, but UI Builder has changed so much I can't get it to work.

 

I'm trying to do something simple to start - I want to get a list of all catalog tasks for a specific requested item and list the data in a dataset component - not a repeater.  (I'm also trying to learn the dataset component).

 

If anyone can add what I need to do to turn the results from the GraphQL data resource into a format that the Dataset component can use, I could use help with that, too.

2 REPLIES 2

Tanushree Maiti
Kilo Patron

You can try with UI Builder - Transform Data Brokers .

 

Refer: UI Builder: How to use a transform data broker to populate a dropdown

            UI Builder - Transform Data Brokers

            https://developer.servicenow.com/blog.do?p=/post/quebec-ui-builder-data-resources/#:~:text=Creating%....

 

 

Also refer this : Using Data from your GraphQL API in UI Builder (Part 3 of 3)

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

lauri457
Tera Sage

The data set component is meant to be used in conjunction with an evam definition Entity view action mapper • Australia ServiceNow AI Platform Capabilities • Docs | ServiceNow

If you look at the example payload in the docs for the data set component you'll notice that it is quite complex. 

 

You can test it out with the "evam data resource" data resource and just bind the compositeDataViews property to the data property in the data set component. 

 

Screenshot 2026-03-30 170627.png

As for graphql are you able to create the api and resolvers or do you struggle with the creation of the data broker? 

 

The schema for an api looks like this. You can use the @source notation to resolve values from a gliderecord directly. Just return the gliderecord object in your resolver for getIncidents for example

schema {
    query: Query
}

type Query {
	   getIncidents(limit: Int = 5): [Incident]
}

type Incident {
	sysId: String @source(value:"sys_id.value")
	number: String @source(value:"number.value")
}

 

For the data broker the query is defined like so, you can also test it out in the graphql explorer. Notice in servicenow you have to include the app namespace and the schema namespace

query($limit: Int){
  x934661 {
    incidentGet {
      getIncidents(limit: $limit) {
        sysId
        number
      }
    }
  }
}

 In trying to figure out evams or graphql apis it is just best to look at what is available oob and try and replicate by copying.