Skip to content

Commit

Permalink
Fixed broken network requests in GraphQL
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewBastin committed Jul 15, 2020
1 parent 1389c7f commit 82409f3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pages/graphql.vue
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,11 @@ export default {
data: JSON.stringify({ query: gqlQueryString, variables }),
}
const data = await sendNetworkRequest(reqOptions, this.$store)
this.response = JSON.stringify(data.data, null, 2)
const res = await sendNetworkRequest(reqOptions, this.$store)
const responseText = new TextDecoder("utf-8").decode(new Uint8Array(res.data))
this.response = JSON.stringify(JSON.parse(responseText), null, 2)
this.$nuxt.$loading.finish()
const duration = Date.now() - startTime
Expand Down Expand Up @@ -626,10 +629,13 @@ export default {
const data = await sendNetworkRequest(reqOptions, this.$store)
const schema = gql.buildClientSchema(data.data.data)
const response = new TextDecoder("utf-8").decode(new Uint8Array(data.data))
const introspectResponse = JSON.parse(response)
const schema = gql.buildClientSchema(introspectResponse.data)
this.$store.commit("setGQLState", {
value: JSON.stringify(data.data.data),
value: JSON.stringify(introspectResponse.data),
attribute: "schemaIntrospection",
})
Expand Down

0 comments on commit 82409f3

Please sign in to comment.