Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@8base/api-client
Advanced tools
Readme
The 8base SDK provides a convient way of initializing an API client to start making GraphQL calls to a workspace.
This client library is used by the other 8base service packages to make requests to the 8base API. You can also use it independently to make custom requests to the API.
The Client
module exposes a number of different methods that can be used to configure itself. Those functions are listed below with relevant descriptions.
In the most basic case, the client can be used to query public resources from a given workspace.
/* Import client module */
import { Client } from '@8base/api-client';
/* Instantiate new instance with workspace endpoint */
const client = new Client('https://api.8base.com/cjz1n2qrk00f901jt2utcc3m0');
/* Run a query with a callback handler */
client.request(`
query {
__schema {
types {
name
}
}
}
`).then(console.log);
Should an idToken
or apiToken
need to get set, the client.setIdToken(tk)
method can be used. Under the hood, this will set the supplied value as a Bearer token header on subsequent requests.
/* Set the Token */
client.setIdToken('MY_API_TOKEN')
/* Run a query with a callback handler */
client.request(`
query {
privateResourceList {
items {
id
}
}
}
`).then(console.log);
Update the id token.
Update the refresh token.
Update the user email.
Update the workspace identifier.
Send request to the API with variables that will be used when executing the query. . Returns promise to be resolved.
/* Set variables */
const variables = {
search: "ste"
}
/* Set query */
const query = /* GraphQL */`
query($search: String!) {
resourceList(filter: {
name: {
contains: $search
}
}) {
items {
id
}
}
}
`
/* Run a query with a callback handler */
client.request(query, variables).then(console.log);
There any a number of ways developers can connect to their workspace and begin executing queries. The Client
module is only one of them! If you're curious about alternatives for how you can create a client, check out the following video. However, remember that all GraphQL calls are only HTTP post requests – and connecting to your 8base workspace is no different!
FAQs
The 8base SDK provides a convient way of initializing an API client to start making GraphQL calls to a workspace.
The npm package @8base/api-client receives a total of 258 weekly downloads. As such, @8base/api-client popularity was classified as not popular.
We found that @8base/api-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.