Skip to content

legalesign/legalesign-graphql-tutorial

Repository files navigation

Quick Example

This NodeJS project shows how to run a query against the Legalesign GraphQL API. We've made every effort to keep this code as simple as possible so that you can bring it into your own projects without difficulty.

Requirements

To run this project you will need:

  • To have registered for an account at https://www.legalesign.com
  • Your Cognito User Pool ID and Client ID (provided by Legalesign)
  • Installed a recent version of NodeJS onto your test machine
  • Installed the Git command line tools (if you intend to setup the project from Git)

Setup

Download the example project on to your test machine. The easiest way to do this is to clone the github project. In your projects folder run the following command from the terminal or shell:

git clone https://github.com/legalesign/legalesign-graphql-tutorial.git

Change directory into the project folder.

cd legalesign-graphql-tutorial

Install the required packages for this project. Note: in this project we are using the lightweight graphql-request library, this is optional and you can use any other client you want.

npm install

Configure your credentials

Copy the example environment file and fill in your details:

cp .env.example .env

Edit .env with your Legalesign credentials and Cognito details:

COGNITO_USER_POOL_ID=your-pool-id
COGNITO_CLIENT_ID=your-client-id
LEGALESIGN_EMAIL=me@yourcorp.com
LEGALESIGN_PASSWORD=your-password
LEGALESIGN_GRAPHQL_URL=https://graphql.uk.legalesign.com/graphql

Your Cognito User Pool ID and Client ID will be provided by Legalesign. Your user account needs to be approved for API access. If you haven't received these, contact support@legalesign.com.

Important: Never commit your .env file to source control. It is already included in .gitignore.

Run the code

From the command line you can test the user information query by entering the following command;

node --env-file=.env userInformation.js

Or you can run the sample code directly from VS Code (if that's your IDE) as the launch.json has been provided. You should see something similar to the output given below:

{
  user: {
    id: 'dXNyM2U5NjQwOTMtNTMzZi00MTdlLWEyYzMtZGNmMWM4M2U5N2Ux',
    name: 'Alex Why',
    email: 'alex.why@legalesign.com',
    memberConnection: { groupMembers: [Array] }
  }
}

For speed we haven't formatted the answer but if you print out all of the JSON using stringify() or just debug the code, you'll see that all the groups that you're a member of are included in the groupMember array.

How to find out more

You find out more on how to write graphQL queries and mutation, plus advice and news from the legalesign technical team at [https://apidocs.legalesign.com/].

About

Example API calls for NodeJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors