Does faunadb have a graphql client?

So we have faunadb-js but it’s really only for FQL, what if we want to be able to use graphql as well? Something like

import gql from 'graphql-tag';

cosnt client = new Client({
  secret: 'some secret',
  domain: 'db.us.fauna.com'
});

// ... later down the line
const response = await client.graphql(
  gql`
    query (userId: ID!) {
      allTodosByUserId (userId: $userId) {
        id
        title
      }
    }
  `,
  {
    userId
  }
);

I’m trying to convince my bosses to use faunadb, since it’s something they haven’t heard of before, I need to make a really solid point that they can’t refute.

1 Like

Take a look at graphql-request (GitHub - prisma-labs/graphql-request: Minimal GraphQL client supporting Node and browsers for scripts or simple apps). You can use a thirdparty graphQL packages to access faunaDB. Just add a graphQL endpoint (How to access GraphQL endpoints | Fauna Documentation) to the package config and your secret key to the header.

1 Like

I also recommend Apollo Client. While it’s optimized for React, it can still be used in other frameworks, or with no framework at all. The in-memory cache is amazing to work with. It all works great along with Fauna, or any other GraphQL server – a solid foundation for any GraphQL project in my opinion.

1 Like

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