Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi to every one,
I need to create one Data Connection for to read some fields in GraphQL
example :
query{
bookings {
id
uuid
}
}
the URL it's something like this :
"https://gm-cms-staging.xyyyy.com/graphql?token=a5OMOWlzCB9zM_os0oS8"
Someone has used REST GET JSON with GraphQL ?
Thanks so much for your help !!
Hi Steeramp,
PS: Text written in Portuguese
Hi Steeramp,
PS: Text written in Portuguese
Hi @steeramp ,
Hope the connection has worked for you. Am trying to make the query dynamic. Have been able to connect with the Rest API and query a table based on the response query in the data connection but it doesn't work when i try and use with connection to query a different table. Any guidance will be helpful.
Thanks!
Hi @salonibhatia ,
Yes, it is possible. Just make your SQL Select using WITH CONNECTION . For example:
let vRequestBody = '{ "query": "{ organizations { id name created_at role} }"}';
let vRequestBody = replace(vRequestBody,'"', chr(34)&chr(34));
LIB CONNECT TO 'mysourceAPI';
RestConnectorMasterTable:
SQL SELECT
"__KEY_data",
(SELECT
"id",
"name",
"created_at",
"role",
"__FK_organizations"
FROM "organizations" FK "__FK_organizations")
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION(Url "https://api.mysource.com/graphql", BODY "$(vRequestBody)");
If you need connect to a sequence of tables, you can loop a list of tables and make a connection for each table.
Regards,
Jean Paul
Thanks @jptneumann
The columns in each table are different. Will the query have to be written every time to get the columns of that particular table? Am sorry for a lot of questions but little confused since if you change the query from organizations to a different table say departments and departments table has different columns, then how do you handle that part?
Thanks in advance 🙂
Hi @jptneumann , found a solution to add columns using a variable in select query as below
Let vColumns = 'a","b","c';
My approach would be to fetch columns somehow automatically in the variable based on table name(still have to work on it); have researched and * doesn't work.
Please do share if there is any better approach.
Thanks,
Saloni
Hi @salonibhatia ,
it is a good option to use variables.
See in the example that the request uses the vRequestBody variable to build the query and it can be changed whenever you need to change the query.
To select the fields according to the table name, I suggest using the combination of Pick and Match functions.
Ex:
Pick(Match(vTable, 'Table1','Table2','Table3'),'Field1, Field2', 'Field3,Field4','Field5,Field6')
I hope I helped you,
Regards,
Jean Paul