1. Mike Fisher
  2. PowerBuilder
  3. Tuesday, 31 March 2020 19:56 PM

I am currently developing applications  in PB 2017. I do have PB 2019 available but have yet to migrate over.

I am aware that PB 2017 & 2019 have REST support but I have not had a use case for it, until recently.

I may need to leverage an API which uses GraphQl instead of REST.

So, does PowerBuilder support GraphQl? Is it possible to leverage the REST capability in PB to execute GraphQl queries and mutations?

Any guidance is much appreciated.

 

 

 

 

 

 

 

 

Mike Fisher Accepted Answer Pending Moderation
  1. Thursday, 16 April 2020 13:19 PM
  2. PowerBuilder
  3. # 1
0
Votes
Undo

I was able to use the PB HttpClient object to successfully make the GraphQl request. The trick was to properly format the request body in the SendRequest function to get a successful result.

I created some simple GraphQl queries in my api client editor and traced them in Fiddler which exposed the proper request body formatting.

As Chris mentioned the JSONParser object works perfect parsing the resulting JSON.

Just need to get a little more comfortable writing GraphQl queries/mutations with arguments, then I should be able to write a simple GraphQl service.

Thanks to all who provided guidance on this.

- Mike

Comment
Glad to hear it worked!
  1. Armeen Mazda @Appeon
  2. Thursday, 16 April 2020 14:18 PM
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 31 March 2020 20:19 PM
  2. PowerBuilder
  3. # 2
1
Votes
Undo

GraphQL provides client libraries for a number of programming languages but not PowerScript.  They do provide client library for C#/.NET.  So what you could theoretically do is use the .NET DLL Importer of PowerBuilder 2019 R2 to import the GraphQL client library for C# and then call the client from PowerScript.  Of course we haven't tested it so cannot tell you for sure if there are any issues/limitations.

Comment
Thank you Armeen.
  1. Mike Fisher
  2. Tuesday, 31 March 2020 20:50 PM
Hi Mike;

AFAIK: GraphQL does not have a direct .Net DLL interface. However, they do have classes that you can download (ie: NuGet) and then use, for example: https://graphql.org/code/#c-net

Using PB2019's support for creating a .Net Assembly or even using Visual Studio, you can create a .Net Core / Framework "assembly" that wrappers the GraphQL .Net package. Once you compile that into a .Net Assembly for the functionality yo would like expose, you can then use that Assembly.DLL directly in PB 2019 R2 using the new ".Net DLL Importer" that Armeen was talking about.

Regards ... Chris
  1. Chris Pollach @Appeon
  2. Tuesday, 31 March 2020 21:30 PM
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 31 March 2020 20:11 PM
  2. PowerBuilder
  3. # 3
1
Votes
Undo

Hi Mike;

  PB does not interface with GraphQL directly however, you can leverage REST web services directly in GraphQL. In fact, you can also do this with RESTful Stored Procedures in ASE, SQL Server and Oracle as other examples. Just use the RESTClient object to communicate with the DBMS directly. However, instead of an ANSI result set, your PB Apps will receive the datum in JSON format.

FYI: GraphQL & Rest

HTH

Regards ... Chris

Comment
Hi Chris,



Thank you for the quick reply.



I'm a bit confused by some of your comments. My apologies for being so dense, this is new territory for me. I guess my big take away is that the PB Rest Client is not going to help me with this problem.



I work in a simple PB/ MS SQL Server environment. If I want to read/update data between my SQL Server DB and a cloud application API (GraphQl) does PB offer any functionality to do this? If not I will look at alternatives (SSIS perhaps).



BTW I have watched most of the HOW TO GRAPHQL tutorials that you referenced. The site is a great resource.



Thank you for the link and patience.





  1. Mike Fisher
  2. Tuesday, 31 March 2020 20:47 PM
Hi Mike;

If you want to interface to GraphQL via SSIS, then you would be doing the same thing as a PB App - that is using a RESTFul interface. The GraphQL server can expose its underlying data via communicating directly to the DBMS via RESTFul web service calls. For example in SSIS: http://www.msbiinfo.com/2019/01/getting-started-with-graphql-in-aspnet.html

PB's RESTFulClient would enable your PB Apps to make the same GraphQL Rest calls and then introspect the JSON data on the way back using PB's new JSONParser object class.

Regards ... Chris

  1. Chris Pollach @Appeon
  2. Tuesday, 31 March 2020 21:21 PM
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.