gecli create gei
To develop a GraphQL Editor Integration use the gecli create gei
command to create your integration project. This will create the monorepository based on npm workspaces. It will contain 2 packages:
Then you should enter the integration
cd packages/integration
npx gecli gei init
to init the empty integration file where you connect your stucco-js
handlers.
integration.ts
import { NewIntegration } from 'graphql-editor-cli';
import { handler } from './rest.js';
export const integration = NewIntegration({
// Integration code here
});
export default integration;
Later on use the gecli gei integrate
command to integrate your TypeScript file to the stucco.json
. Of course this is an empty integration that won't integrate yet. Take a look here:
import { NewIntegration } from 'graphql-editor-cli';
import { handler } from './rest.js';
export const integration = NewIntegration({
Query: {
restProxy: {
name: 'gei-rest',
description: 'Proxy your rest endpoint to GraphQL Schema',
handler,
data: {
passedHeaders: {
name: 'Passed headers',
description:
'Names of headers to pass from `/graphql` request to rest proxy',
value: [],
},
headers: {
name: 'Request headers',
description: 'Insert request headers for REST in format Key:Value',
value: [],
},
body: {
name: 'REST endpoint body',
description: 'REST endpoint body serialized as JSON.',
value: '',
},
url: {
name: 'REST endpoint',
description:
'REST endpoint to map to. Accepts values with $ at the beginning from the GraphQL Query.',
value: 'https://jsonplaceholder.typicode.com/todos/1',
required: true,
},
method: {
name: 'method',
description: 'GET, POST, PUT etc.',
value: 'GET',
},
},
},
},
});
export default integration;
Here is the full integration https://github.com/graphql-editor/. As you can see we connected the handler and added descriptions and values. Value can be of 2 types only:
To prepare your integration to be published first of all please run the
gecli gei integrate
command inside integration package. packages/integration
. This will integrate your integration file with stucco.json
This step is a must as you need to have your integration released somewhere to install it later. Normally we add default github integration file which publishes the integration with your NPM secret.
gecli gei publish
This command will publish your package to GraphQL Editor marketplace. Then you can use it inside GraphQL Editor as a no-code backend block