Skip to content

Overview

NetlifyConnector provides different methods to help you create a connector within your integration.

MethodDescription
defineOptions()Used to define the configuration options your connector will expose in the Netlify UI.
event()(deprecated) Use sync() instead.
init()Used to initialize your connector.
model()Used to define your data model.
proxySchema()Used to define a dynamic connector that builds a GraphQL schema using @graphql-tools modules.
sync()Used to define what happens on initial and subsequent data syncs.

Usage example

import { NetlifyIntegration } from "@netlify/sdk";
// Create an integration
const integration = new NetlifyIntegration();
// Create a connector
const connector = integration.addConnector({
typePrefix: `Example`,
});
// Use the Connector API on the `connector` object
// to define a model with a single document model on it
connector.model(async ({ define }) => {
define.document({
name: "Post",
fields: {
title: {
type: "String",
required: true,
},
},
});
});
// Use the Connector API to configure how data should
// be handled on initial and subsequent syncs. In this example,
// we’re passing in sample data in line.
connector.sync(async ({ models, isInitialSync }) => {
switch (true) {
case isInitialSync: {
models.Post.insert([
{
id: "1",
title: "This is my example post",
},
]);
break;
}
case !isInitialSync: {
models.Post.insert([
{
id: "1",
title: "This is my example post",
},
]);
}
}
});
// export the valid integration object
export { integration };

Got it!

Your feedback helps us improve our docs.