Using faunadb & graphql with cloudflare workers

I already setup a netlify function to connect faunadb with an apollo server, then add a graphcdn on top of it to cache the results! but i need to move these api to cloudflare workers to reduce a data letancy (although its fast, but at the first request takes some 600 ms - 1s to respond)!
can you help me to make a graphql server to connect faunadb, graphql & cloudflare workers?
thanks!

Hi @amancoder28 - for the Cloudflare Workers <-> Fauna part, check out Create a serverless, globally distributed REST API with Fauna in the Cloudflare Workers docs. That will get you setup to deploy to Cloudflare and connect to Fauna from your Worker.

From there, I think handling the incoming GraphQL request should be pretty similar, if not the same. You might be able to reuse your existing code.

1 Like

How about graphql? I really need to use graphql!
there is no starter template like there is for netlify functions?

I might have mis-understood. I thought you meant “run a GraphQL server in Cloudflare Workers that interacts with Fauna.”

If you meant “how can I interact with Fauna using GraphQL,” check out the GraphQL quickstart and GraphQL workshop!

Neither is written for Workers specifically, but you should be able to combine the Workers tutorial and the GraphQL workshop to achieve what you’re trying to do.

Yes! I need run a GraphQL server in Cloudflare Workers that interacts with Fauna! i am trying to use some Libraries, but they dont work at all! I will try as much as i can!

what my problem was I make a request from my client side app, which take to long to reach to large contentful paint about 1 - 2 seconds!

one solution that i have discovered was to move to server side rendering (with html streaming aka rendering while fetching)! as i use solid js, I am waiting for solid start which is an ssr meta framework! but also after the app hydrates i am going to make these requests from the client side!

thanks for helping me!