Best practices for clients to communicate with DB

Hi, I wonder what is the best practice for client to communicate with FaunaDB. Is it:

  • Create a function on FaunaDB via Dashboard, then execute it using the GraphQL request with the @resolver

    image

or

If the 2 approaches are situational, what are the pros and cons of them?
Thanks in advance

depends, the first approach you mentioned requires you to use graphql (although if you use graphql, you might still need to use FQL), the second approach requires you to use only FQL, either way, if you use the built-in authentication properly, there wouldn’t be a problem and also make sure to keep an eye on the security roles, that’s very important for security unless you want everyone to access everything.

1 Like

Whether you use GraphQL with FQL resolvers, or FQL all by itself, I recommend saving your function definitions in version control with a script to create/update them. The dashboard can make it easy to get started, but preferably you’d lock down that definition at some point.

There are some community tools that help with Fauna infrastructure as code. But it looks like you’re using Dart, is that correct? I’m not sure how folks may prefer to do that with Dart.

@aprilmintacpineda April has good points about security – a lot about how you implement your application can hinge upon what kind of security rules you want/need to enforce.

@ptpaterson yea I agree that the dashboard is getting cumbersome as things grows.

So it might be that the best approach would be using either or a combination of:

  • GraphQL with FQL resolvers, which uploaded function definition by code
  • FQL, connected by driver
    either way you still have to ensure the security roles

@ptpaterson I used Dart’s driver to connect to the DB as I’m working on a Flutter project. I’ll have a look as Fauna infrastructure as code you mentioned

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.