diff --git a/pages/graphql.vue b/pages/graphql.vue index 6e2abadc2..ac7e8a5ee 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -30,6 +30,36 @@ }" /> + +
+ + + +
+
+ +
+
+ + + + +
+
+ +
+
+ + + +
+
+ +
+
+ +
+
@@ -43,12 +73,16 @@ import AceEditor from "../components/ace-editor"; export default { components: { "pw-section": () => import("../components/section"), + "gql-field": () => import("../components/graphql/field"), Editor: AceEditor }, data() { return { url: "https://rickandmortyapi.com/graphql", - schemaString: "" + schemaString: "", + queryFields: [], + mutationFields: [], + subscriptionFields: [] }; }, methods: { @@ -69,6 +103,35 @@ export default { this.schemaString = gql.printSchema(schema, { commentDescriptions: true }); + + if (schema.getQueryType()) { + const fields = schema.getQueryType().getFields(); + const qFields = []; + for (const field in fields) { + qFields.push(fields[field]); + } + this.queryFields = qFields; + console.log(this.queryFields); + } + + if (schema.getMutationType()) { + const fields = schema.getMutationType().getFields(); + const mFields = []; + for (const field in fields) { + mFields.push(fields[field]); + } + this.mutationFields = mFields; + } + + if (schema.getSubscriptionType()) { + const fields = schema.getSubscriptionType().getFields(); + const sFields = []; + for (const field in fields) { + sFields.push(fields[field]); + } + this.subscriptionFields = sFields; + } + this.$nuxt.$loading.finish(); const duration = Date.now() - startTime; this.$toast.info(`Finished in ${duration}ms`, {