Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

GraphQl in Talend

Hi everyone,

 

I have to use a GraphQL API in talend but I can't do it.

The goal is to get data from another API with a tjava, then i link the tjava with a tmap and to finish i use the tmap to do a request like : '{"query": "mutation { saveForm(formInput: {wasteDetails{name : ' + row1.wdName + '}) {id,wasteDetails{name}} }" }'

I try 3 differents way.
The first way was with tRest but we can't link a tmap to a tRest

The second way was with a tRestClient but I don't know what put in parameters in my url so I've had a http 500 errors 

And the third way was with thttprequest but i don't know how to use the row of my tmap in my file for the post of the thttprequest

 

I hope I'm clear enough

Thank you in advance

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

First, connect your tRestClient to your tMap. You should see a body and a string column in your tMap output table. In your tMap output table's string column value expression, use this code....

 

"{\"query\": \"mutation\", { \"id\": \""+ row3.WTIERS +"\"}}"

......note the above code is abridged since the code you supplied was not complete. Note the "\" characters used to escape the quotes. You need to keep this in mind with Java String manipulation.

 

Once you have done this, you just need to make sure the tRestClient is configured with the correct endpoint and details. 

 

You may want to test the JSON being produce by replacing the tRestClient with a tLogRow.

View solution in original post

19 Replies
Anonymous
Not applicable
Author

Can you send a screenshot of your job as it is at the moment? It sounds like you are using a Java API (via an imported Jar?) to get your data. You are then building an JSON String with your tMap and then trying to send that to a web service?

If that is correct, I would use a tRestClient to call GraphQL and ensure that your send the JSON via the string column (tRestClient needs either a string or body column....string for JSON, body for XML).

Anonymous
Not applicable
Author

My job looks like that : 

 

0683p000009M65P.png

 

My tjava :

0683p000009M65U.png

 

The result is a huge xml.

 

My tExtractXMLField_1 : 

0683p000009M65Z.png

And my tmap :

0683p000009M65e.png

 

The result of this job is : 

0683p000009M656.png

These are the results I want to put in the graphQl api.

 

So i call an API, this API sends me a xml. With extractXML I take all the datas and they go in my tmap.
Now I have to put these datas in the tRestClient with a query like : '{"query": "mutation { saveForm(formInput: { id: '+ row3.WTIERS +', ....}) {id,wasteDetails{name}} }" }'

To do that I have to use a twritejson ?

Anonymous
Not applicable
Author

First, connect your tRestClient to your tMap. You should see a body and a string column in your tMap output table. In your tMap output table's string column value expression, use this code....

 

"{\"query\": \"mutation\", { \"id\": \""+ row3.WTIERS +"\"}}"

......note the above code is abridged since the code you supplied was not complete. Note the "\" characters used to escape the quotes. You need to keep this in mind with Java String manipulation.

 

Once you have done this, you just need to make sure the tRestClient is configured with the correct endpoint and details. 

 

You may want to test the JSON being produce by replacing the tRestClient with a tLogRow.

Anonymous
Not applicable
Author

It works, thank you very much.

Anonymous
Not applicable
Author

Hello Everyone,

 

I am facing the similar issue while performing the mutation operation

I was able to Query and receive the response as well

But while performing the mutation talend is throwing an error like below

Please find my Job Screenshots attached.....

 

0683p000009M7v9.png0683p000009M7vE.png

0683p000009M7vJ.png

0683p000009M7dc.png0683p000009M7vT.png0683p000009M7il.png

 

Anonymous
Not applicable
Author

It seems to suggest an unexpected character has been used in the JSON you are sending. Can you post the JSON here?

Anonymous
Not applicable
Author

mutation { importEntities: {name: "ABC World"} {id} }

This is the JSON I am trying to POST

 

Thanks,

Archanalg

Anonymous
Not applicable
Author

Hi rhall,

mutation{ upsertEntity(entity: { name:"ABC World"}) {id}}

when I try to post the same JSON in GraphQL Playground Link I am able to receive response,

Please let me know is there any specific component designed to handle GraphQL calls.

 

Thanks in advance,

Archanalg

Anonymous
Not applicable
Author

This is bad JSON. It does not fit JSON standards. Test your JSON out here before posting it. It will help you identify what is wrong with it