DEV Community

Cover image for GraphQL queries with Okta Workflows
Bryan Barrows for Okta Workflows

Posted on

3

GraphQL queries with Okta Workflows

Okta Workflows is a stellar tool for orchestrating automations and has built-in integrations with a wide variety of services. Workflows also makes it easy to communicate with APIs via the API Connector functionality.

A customer recently asked, "What if I need to talk to a GraphQL service? Can Okta Workflows do that?"

Yes! In essence, GraphQL is just a text format used in HTTP payloads, so we can leverage Workflows to generate the queries and the HTTP Functions in the API Connector to make the calls.

Screenshot of attached Okta Workflow that you can import to your environment and test

I found this helpful list of free GraphQL APIs for projects and demos and decided to test out the Star Wars API.


Feel free to check it out :

{"type":"flopack","version":"1.3.0","created":"2022-10-03T22:56:38.788Z","flags":{"auto-transform":true,"looseBooleans":true,"looseStrings":true,"looseNulls":true},"data":{"flos":{"a335e0a2-c92e-4767-be7e-5387fdbbd549":{"id":"a335e0a2-c92e-4767-be7e-5387fdbbd549","name":"GraphQL Query","description":"","data":{"id":null,"uuid":"a335e0a2-c92e-4767-be7e-5387fdbbd549","display":{"preview":[{"module":"control","name":"noop","kernel":true},{"module":"object","name":"construct","kernel":true},{"module":"httpfunctions","name":"post","kernel":false},{"module":"list","name":"pluck","kernel":true},{"module":"object","name":"get","kernel":true},{"module":"control","name":"comment","kernel":true}],"isCallable":false},"tree":{"id":2,"name":"empty","description":"This flow has been build w/o a tree and uses the newer, async, Addressing module."},"methods":[{"joins":{},"address":"root:kernel:control:0.0.1:noop","parents":{"version":{"address":"root:kernel:control:0.0.1","key":"0.0.1","data":{"name":"0.0.1"}},"channel":{"address":"root:kernel:control","key":"control","data":{"name":"control"}}},"uuid":"Ud7aWlL6nQ","branches":{},"node":{"key":"noop","data":{"name":"Noop"},"model":{"type":"method","_v":2,"key":"noop","executable":false,"displayed":true,"async":false,"cooperative":false,"mirrored":false,"inlined":false,"dependencies":[],"timeout":90000,"idempotent":false,"monitor":false,"webhook":false,"webhookList":false,"webhookConditions":false,"mobile":false,"hooks":{},"policy":{"error":{"type":"finish"}},"metadata":{"id":null,"name":"Noop","description":"No-op. Does not do anything."},"meta":{},"config":null,"partnerChannelKeys":null,"inputs":{"extensible":true,"data":{}},"outputs":{"extensible":true,"data":{}},"runtime":{}}},"pins":{}},{"joins":{},"address":"root:kernel:object:0.0.1:construct","parents":{"version":{"address":"root:kernel:object:0.0.1","key":"0.0.1","data":{"name":"0.0.1"}},"channel":{"address":"root:kernel:object","key":"object","data":{"name":"object"}}},"uuid":"IW4L5tzb-","branches":{},"node":{"key":"construct","data":{"name":"Construct"},"model":{"type":"method","_v":2,"key":"construct","executable":false,"displayed":true,"async":false,"cooperative":false,"mirrored":false,"inlined":false,"dependencies":[],"timeout":90000,"idempotent":false,"monitor":false,"webhook":false,"webhookList":false,"webhookConditions":false,"mobile":false,"hooks":{},"policy":{"error":{"type":"finish"}},"metadata":{"id":null,"name":"Construct","description":"Create an object from multiple inputs."},"meta":{},"config":null,"partnerChannelKeys":null,"inputs":{"extensible":true,"rules":{"*":{"types":["*"],"collection":"*"}},"data":{"lhVkmqCb5":{"id":"lhVkmqCb5","group":null,"key":"query","value":{"error":false,"proxy":false,"check":false,"type":"string","collection":false,"data":"{\n allFilms {\n films {\n title\n }\n }\n}","available":["string","number","boolean","Date","Array","object","file","flo","folder"]},"required":false,"ref":false,"metadata":{"index":0,"custom":true},"flags":"d"}}},"outputs":{"extensible":false,"data":{"mgVmLgNLiO":{"id":"mgVmLgNLiO","group":null,"key":"output","value":{"type":"object","collection":false,"data":{}},"ref":false,"metadata":{"index":0},"_used":true}}},"runtime":{}}},"pins":{"mgVmLgNLiO":{"CzuGRKKra":[{"input":"kxl3XWWvD-","transform":null}]}}},{"joins":{},"address":"root:channels:http:httpfunctions:1.0.13:post","parents":{"version":{"address":"root:channels:http:httpfunctions:1.0.13","key":"1.0.13","data":{"name":"1.0.13","id":714}},"channel":{"address":"root:channels:http:httpfunctions","key":"httpfunctions","data":{"name":"httpfunctions","id":72}}},"uuid":"CzuGRKKra","branches":{},"node":{"key":"post","data":{"name":"Post"},"model":{"type":"method","_v":2,"key":"post","executable":true,"displayed":true,"async":true,"cooperative":false,"mirrored":false,"compat":false,"inlined":false,"dependencies":[],"timeout":30000,"idempotent":false,"monitor":false,"webhook":false,"webhookList":false,"webhookConditions":false,"mobile":false,"hooks":{},"policy":{"error":{"type":"finish"}},"metadata":{"id":32595,"name":"Post","description":null},"meta":{},"config":"65697d4d-81e4-466b-9443-4936eb120b64","partnerChannelKeys":226,"inputs":{"extensible":false,"rules":{},"groupRules":{"Request":{"extensible":false,"reserved":{},"index":0,"type":"object"}},"data":{"gvelOLgwtT":{"id":"gvelOLgwtT","group":"Request","key":"URL","value":{"error":false,"proxy":false,"check":false,"type":"string","collection":false,"data":"https://swapi-graphql.netlify.app/.netlify/functions/index","available":["string"]},"required":false,"ref":false,"metadata":{"index":0,"optional":false},"flags":"d"},"B9circeNL-":{"id":"B9circeNL-","group":"Request","key":"Query","value":{"error":false,"proxy":false,"check":false,"type":"object","collection":false,"data":{},"available":["string","object"]},"required":false,"ref":false,"metadata":{"index":1,"optional":false},"flags":"d"},"gP5wf3f9EG":{"id":"gP5wf3f9EG","group":"Request","key":"Headers","value":{"error":false,"proxy":false,"check":false,"type":"object","collection":false,"data":{},"available":["object"]},"required":false,"ref":false,"metadata":{"index":2,"optional":false},"flags":"d"},"kxl3XWWvD-":{"id":"kxl3XWWvD-","group":"Request","key":"Body","value":{"error":false,"proxy":false,"check":false,"type":"object","collection":false,"data":{},"available":["string","object","Array"]},"required":false,"ref":false,"metadata":{"index":3,"optional":false},"flags":"d"}}},"outputs":{"extensible":false,"rules":{},"groupRules":{"Response":{"extensible":false,"reserved":{},"index":0,"type":"object"}},"data":{"hucZ-Eughf":{"id":"hucZ-Eughf","group":"Response","key":"Status Code","value":{"error":false,"type":"number","collection":false,"data":0,"available":["number"]},"ref":false,"metadata":{"index":0}},"pc2Mt278DL":{"id":"pc2Mt278DL","group":"Response","key":"Headers","value":{"error":false,"type":"object","collection":false,"data":{},"available":["object"]},"ref":false,"metadata":{"index":1}},"oORC9p_MyV":{"id":"oORC9p_MyV","group":"Response","key":"Body","value":{"error":false,"type":"object","collection":false,"data":{},"available":["object"]},"ref":false,"metadata":{"index":2},"_used":true}}},"runtime":{},"display":{},"comments":"Perform an HTTP POST request, returning the result of this request and the response headers.","enableNewMetadata":true}},"pins":{"oORC9p_MyV":{"qfwRVHz_H":[{"input":"KywE4t6opX","transform":null}]}}},{"joins":{},"address":"root:kernel:list:0.0.1:pluck","parents":{"version":{"address":"root:kernel:list:0.0.1","key":"0.0.1","data":{"name":"0.0.1"}},"channel":{"address":"root:kernel:list","key":"list","data":{"name":"list"}}},"uuid":"5Z6VbuJsP","branches":{},"node":{"key":"pluck","data":{"name":"Pluck"},"model":{"type":"method","_v":2,"key":"pluck","executable":false,"displayed":true,"async":false,"cooperative":false,"mirrored":false,"inlined":false,"dependencies":[],"timeout":90000,"idempotent":false,"monitor":false,"webhook":false,"webhookList":false,"webhookConditions":false,"mobile":false,"hooks":{},"policy":{"error":{"type":"finish"}},"metadata":{"id":null,"name":"Pluck","description":"Given a list of objects, create a new list using only a specified portion from each object."},"meta":{},"config":null,"partnerChannelKeys":null,"inputs":{"extensible":false,"rules":{"list":{"types":["object"],"collection":true}},"data":{"Oqr8dPD4-k":{"id":"Oqr8dPD4-k","group":null,"key":"list","value":{"type":"object","collection":true,"data":[],"available":[],"error":false},"required":true,"ref":false,"metadata":{"index":0,"ghost":{"displayChannelName":"json","displayName":"Parsed Response","id":"x0_aG9FuL3@"}},"flags":"d"},"2qVntvVyEj":{"id":"2qVntvVyEj","group":null,"key":"key","value":{"type":"string","collection":false,"data":"title","available":[],"error":false},"required":false,"ref":false,"metadata":{"index":1},"flags":"d"}}},"outputs":{"extensible":false,"rules":{"values":{"types":["*"],"collection":true}},"data":{"0N_IZA7DMn":{"id":"0N_IZA7DMn","group":null,"key":"values","value":{"type":"string","collection":true,"data":[],"available":["*"],"error":false},"ref":true,"metadata":{"index":0,"description":"","displayname":"Movie Titles"}}}},"runtime":{}}},"pins":{}},{"joins":{},"address":"root:kernel:object:0.0.1:get","parents":{"version":{"address":"root:kernel:object:0.0.1","key":"0.0.1","data":{"name":"0.0.1"}},"channel":{"address":"root:kernel:object","key":"object","data":{"name":"object"}}},"uuid":"qfwRVHz_H","branches":{},"node":{"key":"get","data":{"name":"Get"},"model":{"type":"method","_v":2,"key":"get","executable":false,"displayed":true,"async":false,"cooperative":false,"mirrored":false,"inlined":false,"dependencies":[],"timeout":90000,"idempotent":false,"monitor":false,"webhook":false,"webhookList":false,"webhookConditions":false,"mobile":false,"hooks":{},"policy":{"error":{"type":"finish"}},"metadata":{"id":null,"name":"Get","description":"Read a value from an object at a given path."},"meta":{},"config":null,"partnerChannelKeys":null,"inputs":{"extensible":false,"rules":{"object":{"types":["object"],"collection":"*"},"path":{"types":["string"],"collection":"*"}},"data":{"KywE4t6opX":{"id":"KywE4t6opX","group":null,"key":"object","value":{"type":"object","collection":false,"data":{},"available":[],"error":false},"required":true,"ref":false,"metadata":{"index":0},"flags":"d"},"NwOFHUhUkD":{"id":"NwOFHUhUkD","group":null,"key":"path","value":{"type":"string","collection":false,"data":"data.allFilms.films","available":[],"error":false},"required":true,"ref":false,"metadata":{"index":1},"flags":"d"}}},"outputs":{"extensible":false,"rules":{"output":{"types":["*"],"collection":"*"}},"data":{"1VSNcGFIdk":{"id":"1VSNcGFIdk","group":null,"key":"output","value":{"type":"object","collection":true,"data":[],"available":["*"],"error":false},"ref":true,"metadata":{"index":0,"description":"","displayname":"List of Films"},"_used":true}}},"runtime":{}}},"pins":{"1VSNcGFIdk":{"5Z6VbuJsP":[{"input":"Oqr8dPD4-k","transform":null}]}}},{"joins":{},"address":"root:kernel:control:0.0.1:comment","parents":{"version":{"address":"root:kernel:control:0.0.1","key":"0.0.1","data":{"name":"0.0.1"}},"channel":{"address":"root:kernel:control","key":"control","data":{"name":"control"}}},"uuid":"FV1F2vS4L","branches":{},"node":{"key":"comment","data":{"name":"Comment"},"model":{"type":"method","_v":2,"key":"comment","executable":false,"displayed":true,"async":false,"cooperative":false,"mirrored":false,"inlined":false,"dependencies":[],"timeout":90000,"idempotent":false,"monitor":false,"webhook":false,"webhookList":false,"webhookConditions":false,"mobile":false,"hooks":{},"policy":{"error":{"type":"finish"}},"metadata":{"id":null,"name":"Comment","description":"Leave a comment."},"meta":{},"config":null,"partnerChannelKeys":null,"inputs":{"extensible":false,"data":{}},"outputs":{"extensible":false,"data":{}},"runtime":{},"display":{},"comments":{"title":"Calling Star Wars GraphQL API","markdown":"We construct our query and call the API. No authentication is necessary for this testing API.\n\nYou can find other APIs to test with here: https://www.apollographql.com/blog/community/backend/8-free-to-use-graphql-apis-for-your-projects-and-demos/\n\nWe use an \"Object - Get\" to grab the list of film objects from the response, then use \"Pluck\" to generate a new list that just contains the titles of the movies."}}},"pins":{}}],"model":{},"orderings":{"E0U1BcCk0":["Ud7aWlL6nQ","IW4L5tzb-"],"uotDdwz-js":["IW4L5tzb-","CzuGRKKra"],"wDoNqwO4GE":["CzuGRKKra","FV1F2vS4L"],"e4kwWkOwQV":["FV1F2vS4L","qfwRVHz_H"],"PiQ_mvWtM_":["qfwRVHz_H","5Z6VbuJsP"]},"cron":{},"security_level":null,"log":true,"inheritLog":true,"scheduled":false,"group":"b7d932ae-d912-49ce-97c4-60d86ce7a162","templateName":null,"connector_method_meta":{"inputs":{},"outputs":{},"options":{}},"monitor_flo":false}}},"configs":{"65697d4d-81e4-466b-9443-4936eb120b64":{"id":"65697d4d-81e4-466b-9443-4936eb120b64","name":"TEST BASIC AUTH","module":"httpfunctions","data":null}},"tables":{},"groups":{"b7d932ae-d912-49ce-97c4-60d86ce7a162":{"id":"b7d932ae-d912-49ce-97c4-60d86ce7a162","data":{"name":"pendo","description":"","media_uri":""}}}},"checksum":"e0d06010b511ca473ed24ed9917ab6402a711f220ae8168623c1479f45fbf5f0"}
Download steps:
  • right click "view raw" in the panel above on the right
  • click "Save Link As"
  • be sure the filename ends in .flow

or check out my other guides and Workflows content (more coming soon!) here:

GitHub logo bbarrows89 / oktaworkflows

tips, flows, and more related to Okta Workflows


Hope this helps! Find me on LinkedIn or shoot me an email if you have any questions.

You can also join us at a Community Office Hours session to work through problems and ask questions - I'd love to see you there.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay