@mfgx/shared-lib-api-client-core
v3.35.0
Published
Client library for MFGx.
Downloads
2
Readme
@mfgx/shared-lib-api-client-core
API client designed to simplify use of MFGx APIs. Works in Node and browser environments.
Install via npm
npm install --save @mfgx/shared-lib-api-client-core
Quick Start (ES6)
import { apiClient } from '@mfgx/shared-lib-api-client-core';
apiClient.setBaseUrl('https://api.instance.mfgx.io');
await apiClient.initiateAuthenticationFlow({
flowType: 'Authentication',
flowData: {
username: '[email protected]',
password: 'password'
}
});
const { data: { userMany } } = await apiClient.graphQL({
query: `{
user {
edges {
node {
id
email
}
}
}
}`
});
Documentation
Exports
import {
// Pre-constructed API client instance with default options.
apiClient,
// Main API client class, used to construct a new instance or extend the client.
MFGxClient,
// Map of MFGx APIs; see APIs section below
APIS
} from '@mfgx/shared-lib-api-client-core';
Constructor Options
{
// Base MFGx API url (i.e. 'https://api.enterprise.mfgx.io'). Can also be set
// or changed via the setBaseUrl function on a client instance.
url,
// Promise-returning functions to get, set, and clear a token from storage.
// Default behavior is to store tokens in local application memory; override provides the
// ability to store tokens in persistent or secure storage.
tokenStorage: {
get,
set,
clear,
},
// When true, token expiration 401 errors will be automatically caught, the
// token will attempt to be refreshed, and the request retried. Defaults to
// false.
autoRefreshToken: false,
// Callback called when errors occur, in addition to normal promise rejection.
// Can be used to display error UI or for global error logging.
onError,
// Promise-returning callback used to request client information when
// needed by the client. Client information returned should match the
// format of the ClientInformationInput type in the Authentication API.
onRequestClientInformation,
}
APIs
{
// Primary GraphQL API for application data.
APPLICATION: '/application',
// GraphQL API used to issue tokens and authenticate to MFGx.
AUTHENTICATION: '/authentication',
INTEGRATION: {
// HTTP RPC-style endpoint which issues requests to external systems via a connector.
CONNECTION: '/integration/connection',
// HTTP endpoint which returns information about a connector.
CONNECTOR: '/integration/connector'
},
// Secondary GraphQL API for system-level data such as enterprise and user information.
SYSTEM: '/system',
// GraphQL API supporting execution of MFGx Scripting Language statements.
TRANSFORMATION: '/transformation',
WEBHOOK: {
// HTTP endpoint which supports publishing data to an MFGx topic.
TOPIC: '/webhook/topic'
},
ORCHESTRATION: {
// HTTP RPC-style endpoint which supports direct execution of an MFGx data flow.
EXECUTE_FLOW: '/orchestration/executeFlow'
}
}