NetlifyConnector
The NetlifyConnector
provides different methods to help create a connector within your integration.
Usage example
Type parameters
Name | Type |
---|---|
ConnectorConfig | ConnectorConfig |
Methods
init
connector.init()
Used to initialize your connector. Returns an object containing initialization state that you can use throughout your connector.
Note that the returned state object is specific to each connector instance. If a data layer contains multiple instances of your connector, each will run its own connector.init(fn)
lifecycle with the relevant configuration options for that instance and store its own state object.
event
Deprecated
connector.event()
is deprecated. Use connector.sync()
instead.
If you have already built an integration that uses this API, you can pass a single function to connector.sync()
instead and use the isInitialSync
variable to determine which logic to run.
Before:
After:
If you previously set connector.event('updateNodes', false)
to ensure every sync is a full data sync (with no caching), you need to configure your connector with the following setting:
model
connector.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:document
: used to define a document model.nodeModel
: deprecated. Usedocument
instead.object
: used to define an object type.union
: used to define a union type.enum
: used to define an enum type.inlineObject
: used to define an object type without an explicit name set in the definition.inlineUnion
: used to define a union type without an explicit name set in the definition.inlineEnum
: used to define an enum type without an explicit name set in the definition.
configOptions
object that contains the configuration values set for options defined usingdefineOptions
.state
object that contains data stored duringconnector.init()
.
Learn more about defining your data model.
sync
connector.sync()
Used to define happens when data initially syncs from your data source into a Netlify Connect data layer.
Also used to define what happens when a sync occurs to update the data — either an automatic sync that a webhook triggers or a manual sync that a user triggers in the Netlify UI.
Has access to the following:
models
: object that contains all defined document models.cache
: helper for storing and accessing non-node data (like CMS sync tokens).isInitialSync
: a boolean that will betrue
on initial data syncs andfalse
on subsequent data syncs.options
: object that contains the configuration values set for options defined usingdefineOptions
.state
: object that includes data stored duringconnector.init()
.
Learn more about specifying how to create and update data.
Example usage:
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.