Log in to GraphQL Editor
Docs
Projects Cloud

Develop your integrations | GraphQL CLI

Development

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:

  • packages/integration main integration package where you should create gei integration.
  • packages/sandbox place where integration can be safely tested. You will need sandbox not to pollute the main integration with example data

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:

  • string
  • string[] If you need other type in your integration you need to parse those strings. We've made that design choice to make it compatible with no-code.

Publishing

Integrate Stucco

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

npm

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.

GraphQL Editor Marketplace

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