hasura / learn-graphql

Real world GraphQL tutorials for frontend developers with deadlines!
https://hasura.io/learn/
MIT License
1.2k stars 651 forks source link

3rd party api in GraphQL #423

Closed beachstrider closed 3 years ago

beachstrider commented 3 years ago

Hi, thanks hasura team for the awesome engine!

These days I am learning graphql and hasura. Now I see that I can just connect to gql server from frontend without backend.

However, what if I use 3rd party api?

e.g. I was building SaaS webapp - inbound call center like Ringba. At first, I just built all tables and graphql using hasura GUI, and then I directly used it on frontend - nextjs. After that, I needed to integrate twilio api in order to make functionalities work live. So I made services in nodejs and mixed them together.

Finally I was wondering whether this is a right way. Because I heard rest api is able to be replaced with graphql completely.

Should I mix graphql and rest api together for such things? Or is there another way?

Any quick hint would be appreciated!

praveenweb commented 3 years ago

However, what if I use 3rd party api?

Your initial approach is right. Write custom code in nodejs for twilio api. Now this API can be added to Hasura's GraphQL layer through Actions by defining the right GraphQL schema and types.

Once an Action is added, you can query it through the same GraphQL endpoint from your frontend and Hasura will make the call to your nodejs webhook.

beachstrider commented 3 years ago

I didn't know about hasura action. Now I am going to study it. Thank you very much for your direction!