7.2.0 • Published 10 months ago

@enonic-types/guillotine v7.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

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!'
          }
        },
      }
    }
  }
};
7.2.0

10 months ago

7.1.1

1 year ago

7.1.0-RC1

1 year ago

7.1.0

1 year ago

7.1.0-B2

1 year ago

7.1.0-B1

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago