NetlifyConnector
The NetlifyConnector
provides different methods to help create a connector within your integration.
Usage example
import { NetlifyIntegration } from "@netlify/sdk";
// create an integration
const integration = new NetlifyIntegration();
// and a connector
const connector = integration.addConnector({
typePrefix: `Example`,
});
// use connector APIs on this object
connector.event(`createAllNodes`, async ({ models }, configOptions) => {
models.Example.createNode({
id: 1,
});
});
export { integration };
Type parameters
Name | Type |
---|---|
ConnectorConfig | ConnectorConfig |
Methods
model
model
Used to define your data model. This model validates inserted data and Netlify uses it to create the GraphQL schema for your connector.
Has access to the following:
define
, which contains the following methods:nodeModel
: used to define a node model.object
: used to define an object type.union
: used to define a union type.
- a
configOptions
object that contains the configuration values set for options defined usingdefineOptions
.
Learn more about defining your data model.
event
event
Used to define what should occur during a createAllNodes
event and an updateNodes
event.
Has access to the following:
- a
models
object that contains all defined node models. - a
cache
helper that can be used to store and access non-node data. - a
configOptions
object that contains the configuration values set for options defined usingdefineOptions
.
Learn more about specifying how to create and update data.
defineOptions
defineOptions
Used to define the configuration options your connector will expose in the Netlify UI.
Has access to zod
, which you use to create and return a Zod object that contains your options.
Learn more about configuring options for the Netlify UI.