So the file you’re referencing above, schema.prisma
, is specific to Prisma2, which is used by Redwood for SQL database support (as I mentioned in the first post of this topic). Basically you won’t work in the api/prisma/
directory. Instead you’ll be in the api/src/
directory.
For something like this you will need to write your own SDL and Services (effectively resolver functions). The difference is that the functions in your services won’t talk to the database. For example, this is a snippet from the Tutorial api/src/services/posts/posts.js
:
export const posts = () => {
return db.post.findMany()
}
...
The db.
above is specific to the database (via the Prisma2 setup), and this is the function behind the query for all posts in posts.sdl.js
. In the case of integrating with Sendgrid to send mail, for example, the db.
would instead be something like sendgrid.
. And the function body would be specific to something like sending an email.
Also to note, just because our built-in support is currently for MySQL, PostgreSQL, and SQLite, there’s nothing blocking you from creating your own GraphQL queries, mutations, and resolvers for other databases like Firebase, MongoDB, Fauna, etc. You just need to manually write the SDL and service functions.
There’s definitely some complexity here. But I hope you have enough to at least explore a bit and see what’s possible.
Some resources that might be of help to learn more about GraphQL specifically:
- Introduction to GraphQL
- React + Apollo Client Tutorial
- Haven’t tried this one, but it looked like it has potential --> " GraphQL File Uploads with React Hooks, TypeScript & Amazon S3"