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

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, 28 March 2024 15:30 PM UTC
  2. PowerBuilder
  3. # 1

Hi Rajkumar,

Unfortunately I know longer have the PB GraphQL code. It was for a proof of concept project that was discontinued. I do seem to recall finding a GraphQL client developed in PB2019 on GitHub back when I was working on this. I was working in PB2017 at the time so I never pursued it but you might want to check and see if it still exists.

Comment
  1. Rajkumar K S
  2. Thursday, 28 March 2024 16:31 PM UTC
Hi Mike,

Thank you for your reply.

If you are providing some code we would be grateful to do our code analysis.



Thanks

Rajkumar
  1. Helpful
There are no comments made yet.
Rajkumar K S Accepted Answer Pending Moderation
  1. Thursday, 28 March 2024 14:07 PM UTC
  2. PowerBuilder
  3. # 2

Hi Mike,

Could you please share some sample code for GraphQl. 

Thanks 

Rajkumar KS

Comment
There are no comments made yet.
Mike Fisher Accepted Answer Pending Moderation
  1. Thursday, 16 April 2020 13:19 PM UTC
  2. PowerBuilder
  3. # 3

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
  1. Armeen Mazda @Appeon
  2. Thursday, 16 April 2020 14:18 PM UTC
Glad to hear it worked!
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 31 March 2020 20:19 PM UTC
  2. PowerBuilder
  3. # 4

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
  1. Mike Fisher
  2. Tuesday, 31 March 2020 20:50 PM UTC
Thank you Armeen.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 31 March 2020 21:30 PM UTC
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. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 31 March 2020 20:11 PM UTC
  2. PowerBuilder
  3. # 5

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
  1. Mike Fisher
  2. Tuesday, 31 March 2020 20:47 PM UTC
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. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 31 March 2020 21:21 PM UTC
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. Helpful
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.