Using REST instead of GraphQL

Is there any examples in the docs on writing restful endpoints rather than using graphql?

Hello, there is a page about using custom Functions: Cookbook - Custom Function : RedwoodJS Docs.

You can still make use of your services, database, etc. from within one.

Just keep security in mind, as Redwood provides none on its own. But there is a section and package for using webhooks: Docs - Webhooks : RedwoodJS Docs.


I guess to know what is your use case for the REST support?

There are libraries like that could generate REST endpoints from your GraphQL API automatically.
Helps if you want to maintain a single API and still support REST consumers.
Would be interesting to see what are the needs of the Redwood community around this and we could adjust and improve SOFA according to it

1 Like

Welcome to the forums @Urigo :rocket:!

I know a common point that is made in Blitz’s favor is their “Zero-API” data layer abstraction that “eliminates the need for REST/GraphQL.” In theory this allows developers to mostly ignore writing any API logic.

In reality this isn’t exactly the case, but their abstraction seems to have struck a nerve with users so I’d be curious if using SOFA would still involve creating a REST API like usual or if it provides extra features to simplify interacting with that REST API?

I mean, the question is, do we want people to write queries or not?
There are solutions also without…

Howdy @guledali! Funnily enough I just had this conversation with @mojombo and @thedavid about an hour ago!

I bet that with not too much work you could convert over the Cell architecture to make RESTful calls instead of GraphQL calls. You could keep the same behavior (show <Loading> while waiting for a response, show <Empty> if no data, show <Success> on completion, etc.)

Instead of useQuery here you could use node-fetch or a similar package that provides something similar to the useQuery states of loading and error (or create those states yourself wrapping node-fetch or something similar)

If you do this I’d personally love to see a PR that made this a potential option for the web-side when generating a Redwood app. We’ve looked into doing something similar with tRPC.