import gql from 'graphql-tag' // eslint-disable-line no-unused-vars
import apolloProvider from '../plugins/apollo'

export default {
    async get(projectUid){
        try{
            const response = await apolloProvider.defaultClient.query({
                query: gql`
                    query learning($projectUid: Int!) {
                        learning(projectUid: $projectUid) {
                            projectUid
                            order
                            type 
                            startX
                            startY 
                            lastX
                            lastY
                            width
                            height
                            goodImage
                            missingImage
                            goodPath
                            missingPath
                        
                    }
                }`,

                fetchPolicy: 'no-cache',
                variables: { projectUid: projectUid }
            })

            let learning = response.data.learning

            if (!learning) return ''

            if (learning.errors)  throw new Error(learning.errors[0])
            
            return learning

        }catch (e) { 
            console.log(e)
            throw e 
        }
    },


}