GraphQL Create an API Demo - Learn Integrations on the Now Platform
[Music] in this video we'll use the information from the previous several videos to create a new API Define the schema security resolvers and resolver mappings then we'll run some test queries to validate our work let's get started our objective is to create a graphql API for Misty Mountain Adventures who already have an app to track cases their clients have encountered on recent Adventures here's the table of cases they would like to access now since this API will be tied to the Misty Mountain scope we'll start by setting our application scope here next we'll navigate to All System web services graphql graphql apis and create a new record we'll give the record name case queries and note that the schema Nam space automatically populates before we get to the details of the schema we'll go down to the security section and turn off ACL authorization now back to the schema we see we've already got the basic blocks in place and all we need to do is fill in our details we'll start by creating a couple of simple query functions called get cases and get case get cases has a few parameters for query string optional filter for the customer ID and limit on how many records to retrieve get case simply accepts a mandatory ID and Returns the details of course we have to to define the type case or none of this will work so down here we'll create a new type case behind the scenes the case table is extended from task which gives us over 60 fields to choose from but our schema is only going to expose these fields if you watch the earlier video on resolvers you'll remember the at source directive helps us retrieve individual field values from a Glide record object retrieved by the resolver let's save our API record and build that resolver now down in the related list we'll create a new graphql scripted resolver record we'll call it get case in our script we'll use env. getet arguments to check which parameters have been provided and add them to the Glide record query at the end we simply return a Glide record object if the query called for multiple records there's an implicit while loop that retrieves as many as necessary let's click submit here and go to the graphql resolver mappings related list and click new this is the part that's often forgotten so don't forget your mappings in the path we can see the various case fields and two queries let's choose query get case and map it to the only resolver we have get case then click submit we'll quickly create another mapping for query get cases to the same resolver finally we'll use a query to test retrieving a case and with a quick modification we can test getting multiple cases notice that the response only gave us four Fields number short description State and impact even though the schema has several more and we know that the case record has even more than that which are not exposed via the schema the reason we only got four is because the query only asks specifically for those four Fields hopefully you're starting to see the power and flexibility of graphql apis we'll look at some of the additional features such as going beyond the basic data types to more complex data in the next video I hope you'll join me
https://www.youtube.com/watch?v=pGRdddYyapk