@enonic-types/guillotine
TypeScript icon, indicating that this package has built-in type declarations

7.1.1 • Public • Published

Guillotine types

Type definitions for Guillotine - augmentable GraphQL Content API for Enonic XP.

Usage

import type {GraphQL, Extensions} from '@enonic-types/guillotine';


import {ObjectTypeName} from '@enonic-types/guillotine';


const MY_OBJECT_TYPE_NAME = 'MyObjectType';
const MY_FIELD_NAME = 'myField';


export const extensions = (graphQL: GraphQL): Extensions => {
  return {
    types: {
      [MY_OBJECT_TYPE_NAME]: {
        description: 'Description for my object type',
        fields: {
          myString: {
            type: graphQL.nonNull(graphQL.GraphQLString),
          }
        }
      }
    },
    creationCallbacks: {
      [ObjectTypeName.Content]: (params) => {
        params.addFields({
          [MY_FIELD_NAME]: {
            type: graphQL.reference(MY_OBJECT_TYPE_NAME)
          }
        });
      }
    },
    resolvers: {
      [ObjectTypeName.Content]: {
        [MY_FIELD_NAME]: () => {
          const {
            // args,
            // localContext,
            source: content
          } = env;
          if (content.type === 'portal:fragment') {
            return null;
          }
          return {
            myString: 'Hello, World!'
          }
        },
      }
    }
  }
};

Package Sidebar

Install

npm i @enonic-types/guillotine

Weekly Downloads

11

Version

7.1.1

License

Apache-2.0

Unpacked Size

51.7 kB

Total Files

35

Last publish

Collaborators

  • edloidas
  • cwe_at_enonic.com
  • alansemenov