@teammachine/sdk v0.2.1
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
- Use
npm
to install the sdk package from Team Machine i.e.npm install @teammachine/sdk
There are several peer dependencies that you will also need to install, see
package.json
for a full list.Include the
authenticated.html
file distributed in theetc
directory, as a publicly accessible route in your application.For
create-react-app
, simply dropping this file into thepublic
directory will be enough.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 intonpm 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