import { GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLString } from 'graphql';

import { createModuleNameFromMetaUrl } from '../../../_helpers/common';

export const PAYLOAD_NAME = createModuleNameFromMetaUrl(import.meta.url);

export default new GraphQLInputObjectType({
  name: PAYLOAD_NAME,
  fields: {
    id: {
      type: GraphQLInt,
    },
    displayName: {
      type: GraphQLString,
    },
    description: {
      type: GraphQLString,
    },
    permissions: {
      type: new GraphQLList(
        new GraphQLInputObjectType({
          name: `${PAYLOAD_NAME}_permissionsModules_permissions`,
          fields: {
            id: {
              type: GraphQLInt,
            },
            displayName: {
              type: GraphQLString,
            },
            description: {
              type: GraphQLString,
            },
          },
        }),
      ),
    },
  },
});
