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: {
    sortBy: {
      type: GraphQLString,
    },
    sortOrder: {
      type: GraphQLString,
    },
    page: {
      type: GraphQLInt,
    },
    pageSize: {
      type: GraphQLInt,
    },
    timezone: {
      type: GraphQLString,
    },
    adFormat: {
      type: GraphQLString,
    },
    demandSources: {
      type: new GraphQLList(GraphQLString),
    },
    widgetIds: {
      type: new GraphQLList(GraphQLString),
    },
    countries: {
      type: new GraphQLList(GraphQLString),
    },
    domains: {
      type: new GraphQLList(GraphQLString),
    },
    devices: {
      type: new GraphQLList(GraphQLString),
    },
    range: {
      type: new GraphQLInputObjectType({
        name: `${PAYLOAD_NAME}_ranges`,
        fields: {
          stringFrom: {
            type: GraphQLString,
          },
          stringTo: {
            type: GraphQLString,
          },
          timezone: {
            type: GraphQLString,
          },
        },
      }),
    },
    interval: {
      type: new GraphQLInputObjectType({
        name: `${PAYLOAD_NAME}_interval`,
        fields: {
          unit: {
            type: GraphQLString,
          },
          value: {
            type: GraphQLInt,
          },
        },
      }),
    },
  },
});
