0.2.1 • Published 4 years ago

@teammachine/sdk v0.2.1

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

Team Machine JS SDK

A Javascript client library providing a convenience wrapper around the Team Machine GraphQL API.

Pre-requisites

  • You / your users need to have a Team Machine user account
  • This SDK is only consumable client-side using a modern web application e.g. an app created using create-react-app.

Installation

  1. Use npm to install the sdk package from Team Machine i.e.
    npm install @teammachine/sdk
  2. There are several peer dependencies that you will also need to install, see package.json for a full list.

  3. Include the authenticated.html file distributed in the etc directory, as a publicly accessible route in your application.

    For create-react-app, simply dropping this file into the public directory will be enough.

  4. The desired auth redirect URL, typically the landing page of your app after authentication, must be whitelisted by the Team Machine platform.

    Contact Team Machine support if this is not already the case.

For local development

As above, except replace the npm install step with the following:

  • npm link from the directory this repo has been cloned into
  • npm link @teammachine/sdk from the directory of the project using the SDK

Configuration

See client.js for default settings. Call @teammachine/sdk.configure() to override as desired.

Usage

import gql from "graphql-tag";
import { request } from "@teammachine/sdk";

(async () => {
  const query = gql`
    query {
      Identity {
        tm_id
      }
    }
  `;

  const result = await request(query);

  console.log(result);
})();

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

TBC