@accounts packages are modular by nature and can be manually installed and configured, however we provide
@accounts/boost - a package containing useful abstractions to get a GraphQL accounts server started with minimal configuration.
Install the core
Choose your database database driver
Choose your authentication services
The following starts an accounts server using the database, transport, and authentication services you provided with the default settings.
Start the accounts server
At this point you will have an accounts GraphQL server running at http://localhost:4003 with a GraphQL playground available at the same address.
Configuring additional options, such as providing custom connection options for a database or additional parameters based on your chosen packages can be achieved by supplying an options object when initializing the
Assuming you've installed the following packages,
@accounts/password the default mongo connection options will be applied and a database called
accounts-js will be used.
Out of the box
@accounts/password is preconfigured to allow users to sign up with usernames or email addresses.
Usage with an existing GraphQL server
A GraphQL server can be extended with accounts functionality by using the
This function will return the type definitions, resolvers, schema directives, the accounts GraphQL context function used for authentication, and finally the executable GraphQL schema.
These variables should then be referenced when creating your GraphQL server.
Adding accounts to a GraphQL server
Usage as a GraphQL microservice
Based on your requirements it can be advantageous to deploy a single accounts server which is then consumed by multiple apps.
The following examples will show you how to setup a GraphQL server which can be used to authenticate requests via JWT token.
First start an accounts server:
Next you need to configure your existing GraphQL server to authenticate incoming requests by using the context function provided by
accountsBoost. Additionally you may merge your existing GraphQL server schema with the accounts server schema.