/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/authorization-code.aurora.yaml
 */
import gql from 'graphql-tag';

export const fields = `
  rowId
  code
  clientId
  client {
    id
    rowId
    grantType
    scopeOptions
    name
    isMaster
    secret
    authUrl
    redirect
    accessTokenLifetimeSeconds
    refreshTokenLifetimeSeconds
    isActive
  }
  accountId
  redirectUri
  scopes
  codeChallenge
  codeChallengeMethod
  expiresAt
  isUsed
  createdAt
  updatedAt
`;

// default methods
export const paginationQuery = gql`
  query OAuthPaginateAuthorizationCodes($query: QueryStatement, $constraint: QueryStatement) {
    pagination: oAuthPaginateAuthorizationCodes(query: $query, constraint: $constraint) {
      total
      rows
      count
    }
  }
`;

export const getQuery = gql`
  query OAuthGetAuthorizationCodes($query: QueryStatement, $constraint: QueryStatement) {
    objects: oAuthGetAuthorizationCodes(query: $query, constraint: $constraint) {
      id
      #FIELDS
    }
  }
`;
export const findByIdQuery = gql`
  query OAuthFindAuthorizationCodeById($id: ID, $constraint: QueryStatement) {
    object: oAuthFindAuthorizationCodeById(id: $id, constraint: $constraint) {
      id
      #FIELDS
    }
  }
`;
export const findQuery = gql`
  query OAuthFindAuthorizationCode($query: QueryStatement, $constraint: QueryStatement) {
    object: oAuthFindAuthorizationCode(query: $query, constraint: $constraint) {
      id
      #FIELDS
    }
  }
`;

export const createMutation = gql`
  mutation OAuthCreateAuthorizationCode (
    $payload: OAuthCreateAuthorizationCodeInput!
  ) {
    oAuthCreateAuthorizationCode (
      payload: $payload
    ) {
      ${fields}
    }
  }
`;

export const insertMutation = gql`
  mutation OAuthCreateAuthorizationCodes($payload: [OAuthCreateAuthorizationCodeInput]!) {
    oAuthCreateAuthorizationCodes(payload: $payload)
  }
`;

export const updateByIdMutation = gql`
  mutation OAuthUpdateAuthorizationCodeById (
    $payload: OAuthUpdateAuthorizationCodeByIdInput!
    $constraint: QueryStatement
  ) {
    oAuthUpdateAuthorizationCodeById (
      payload: $payload
      constraint: $constraint
    ) {
      ${fields}
    }
  }
`;

export const updateMutation = gql`
  mutation OAuthUpdateAuthorizationCodes (
    $payload: OAuthUpdateAuthorizationCodesInput!
    $query: QueryStatement
    $constraint: QueryStatement
  ) {
    oAuthUpdateAuthorizationCodes (
      payload: $payload
      query: $query
      constraint: $constraint
    ) {
      ${fields}
    }
  }
`;

export const deleteByIdMutation = gql`
  mutation OAuthDeleteAuthorizationCodeById (
    $id: ID!
    $constraint: QueryStatement
  ) {
    oAuthDeleteAuthorizationCodeById (
      id: $id
      constraint: $constraint
    ) {
      ${fields}
    }
  }
`;

export const deleteMutation = gql`
  mutation OAuthDeleteAuthorizationCodes (
    $query: QueryStatement
    $constraint: QueryStatement
  ) {
    oAuthDeleteAuthorizationCodes (
      query: $query
      constraint: $constraint
    ) {
      ${fields}
    }
  }
`;
