import { useContentGqlHandler } from "./useContentGqlHandler" ; import { GQLHandlerCallableParams } from "./useGqlHandler" ; const fruitFields = `
    id
    createdOn
    createdBy {
        id
        displayName
        type
    }
    savedOn
    meta {
        title
        modelId
        version
        locked
        publishedOn
        status
        revisions {
            id
            name
        }
    }
    # user defined fields
    name
    numbers
    email
    url
    lowerCase
    upperCase
    date
    dateTime
    dateTimeZ
    time
    rating
    isSomething
    description
    slug
` ; const errorFields = `
    error {
        code
        message
        data
    }
` ; const getFruitQuery = `
    query GetFruit($revision: ID!) {
        getFruit(revision: $revision) {
            data {
                ${ fruitFields }
            }
            ${ errorFields }
        }
    }
` ; const getFruitsByIdsQuery = `
    query GetFruits($revisions: [ID!]!) {
        getFruitsByIds(revisions: $revisions) {
            data {
                ${ fruitFields }
            }
            ${ errorFields }
        }
    }
` ; const listFruitsQuery = `
    query ListFruits(
        $where: FruitListWhereInput
        $sort: [FruitListSorter]
        $limit: Int
        $after: String
    ) {
        listFruits(where: $where, sort: $sort, limit: $limit, after: $after) {
            data {
                ${ fruitFields }
            }
            meta {
                cursor
                hasMoreItems
                totalCount
            }
            ${ errorFields }
        }
    }
` ; const createFruitMutation = `
    mutation CreateFruit($data: FruitInput!) {
        createFruit(data: $data) {
            data {
                ${ fruitFields }
            }
            ${ errorFields }
        }
    }
` ; const createFruitFromMutation = `
    mutation CreateFruitFrom($revision: ID!) {
        createFruitFrom(revision: $revision) {
            data {
                ${ fruitFields }
            }
            ${ errorFields }
        }
    }
` ; const updateFruitMutation = `
    mutation UpdateFruit($revision: ID!, $data: FruitInput!) {
        updateFruit(revision: $revision, data: $data) {
            data {
                ${ fruitFields }
            }
            ${ errorFields }
        }
    }
` ; const deleteFruitMutation = `
    mutation DeleteFruit($revision: ID!) {
        deleteFruit(revision: $revision) {
            data
            ${ errorFields }
        }
    }
` ; const publishFruitMutation = `
    mutation PublishFruit($revision: ID!) {
        publishFruit(revision: $revision) {
            data {
                ${ fruitFields }
            }
            ${ errorFields }
        }
    }
` ; const unpublishFruitMutation = `
    mutation UnpublishFruit($revision: ID!) {
        unpublishFruit(revision: $revision) {
            data {
                ${ fruitFields }
            }
            ${ errorFields }
        }
    }
` ; export const useFruitManageHandler = ( params ) => { const contentHandler = useContentGqlHandler ( params ) ; return { ... contentHandler , async getFruit ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : getFruitQuery , variables } , headers } ) ; } , async getFruitsByIds ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : getFruitsByIdsQuery , variables } , headers } ) ; } , async listFruits ( variables = { } , headers = { } ) { return await contentHandler . invoke ( { body : { query : listFruitsQuery , variables } , headers } ) ; } , async createFruit ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : createFruitMutation , variables } , headers } ) ; } , async createFruitFrom ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : createFruitFromMutation , variables } , headers } ) ; } , async updateFruit ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : updateFruitMutation , variables } , headers } ) ; } , async deleteFruit ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : deleteFruitMutation , variables } , headers } ) ; } , async publishFruit ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : publishFruitMutation , variables } , headers } ) ; } , async unpublishFruit ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : unpublishFruitMutation , variables } , headers } ) ; } } ; } ;