Fixed broken network requests in GraphQL

This commit is contained in:
Andrew Bastin
2020-07-15 14:09:05 -04:00
parent 1389c7f4be
commit 82409f3ccc

View File

@@ -526,8 +526,11 @@ export default {
data: JSON.stringify({ query: gqlQueryString, variables }), data: JSON.stringify({ query: gqlQueryString, variables }),
} }
const data = await sendNetworkRequest(reqOptions, this.$store) const res = await sendNetworkRequest(reqOptions, this.$store)
this.response = JSON.stringify(data.data, null, 2)
const responseText = new TextDecoder("utf-8").decode(new Uint8Array(res.data))
this.response = JSON.stringify(JSON.parse(responseText), null, 2)
this.$nuxt.$loading.finish() this.$nuxt.$loading.finish()
const duration = Date.now() - startTime const duration = Date.now() - startTime
@@ -626,10 +629,13 @@ export default {
const data = await sendNetworkRequest(reqOptions, this.$store) 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", { this.$store.commit("setGQLState", {
value: JSON.stringify(data.data.data), value: JSON.stringify(introspectResponse.data),
attribute: "schemaIntrospection", attribute: "schemaIntrospection",
}) })