Skip to content

Commit

Permalink
Added running state to graphql component
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning committed Jan 31, 2025
1 parent c38a71c commit ed6a19b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions resources/js/components/Graphql.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default {
data: () => ({
data: null,
cachePrefix: 'graphql_',
running: false,
}),
render() {
Expand Down Expand Up @@ -68,6 +69,7 @@ export default {
},
async runQuery() {
this.running = true
try {
let options = {
headers: {
Expand All @@ -81,6 +83,7 @@ export default {
if (this.check) {
if (!this.check(response?.data)) {
this.running = false
Turbo.visit(window.url(this.redirect))
return false
}
Expand All @@ -94,6 +97,8 @@ export default {
} catch (error) {
console.error(error)
this.errorCallback(this.variables, await error?.response?.json())
} finally {
this.running = false
}
},
},
Expand Down
6 changes: 6 additions & 0 deletions resources/js/components/GraphqlMutation.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { computed } from 'vue';
import { GraphQLError, combiningGraphQL, magentoGraphQL } from '../fetch'
export default {
Expand Down Expand Up @@ -199,5 +200,10 @@ export default {
})
},
},
computed: {
running() {
return this.mutating
}
}
}
</script>

0 comments on commit ed6a19b

Please sign in to comment.