const gql = require('graphql-tag')

const typeDef = gql`
  type CustomInfoRequest {
    id: ID!
    enabled: Boolean
    customRequest: JSON
  }

  input CustomRequestInputField {
    choiceList: [String]
    constraintType: String
    type: String
    numDigits: String
    label1: String
    label2: String
  }

  input CustomRequestInputScreen {
    text: String
    title: String
  }

  input CustomRequestInput {
    name: String
    input: CustomRequestInputField
    screen1: CustomRequestInputScreen
    screen2: CustomRequestInputScreen
  }

  type CustomRequestData {
    customerId: ID
    infoRequestId: ID
    override: String
    overrideAt: DateTimeISO
    overrideBy: ID
    customerData: JSON
    customInfoRequest: CustomInfoRequest
  }

  type Query {
    customInfoRequests(onlyEnabled: Boolean): [CustomInfoRequest] @auth
    customerCustomInfoRequests(customerId: ID!): [CustomRequestData] @auth
    customerCustomInfoRequest(
      customerId: ID!
      infoRequestId: ID!
    ): CustomRequestData @auth
  }

  type Mutation {
    insertCustomInfoRequest(
      customRequest: CustomRequestInput!
    ): CustomInfoRequest @auth
    removeCustomInfoRequest(id: ID!): CustomInfoRequest @auth
    editCustomInfoRequest(
      id: ID!
      customRequest: CustomRequestInput!
    ): CustomInfoRequest @auth
    setAuthorizedCustomRequest(
      customerId: ID!
      infoRequestId: ID!
      override: String!
    ): Boolean @auth
    setCustomerCustomInfoRequest(
      customerId: ID!
      infoRequestId: ID!
      data: JSON!
    ): Boolean @auth
  }
`

module.exports = typeDef
