diff --git a/pages/graphql-to-introspection-json.tsx b/pages/graphql-to-introspection-json.tsx index 6fe4ad2..912a002 100644 --- a/pages/graphql-to-introspection-json.tsx +++ b/pages/graphql-to-introspection-json.tsx @@ -19,7 +19,8 @@ export default function() { const result = await graphqlWorker.send({ type: GraphqlTransforms.TO_INTROSPECTION_JSON, - value + value, + extension: "json" }); return prettierWorker.send({ diff --git a/pages/graphql-to-java.tsx b/pages/graphql-to-java.tsx index 38a405c..7f5b4a6 100644 --- a/pages/graphql-to-java.tsx +++ b/pages/graphql-to-java.tsx @@ -1,5 +1,5 @@ -import { useCallback } from "react"; import * as React from "react"; +import { useCallback } from "react"; import ConversionPanel, { Transformer } from "@components/ConversionPanel"; import { getWorker } from "@utils/workerWrapper"; import GrapqlWorker from "@workers/graphql.worker"; @@ -17,12 +17,10 @@ export default function() { graphqlWorker = graphqlWorker || getWorker(GrapqlWorker); prettierWorker = prettierWorker || getWorker(PrettierWorker); - const result = await graphqlWorker.send({ + return graphqlWorker.send({ type: GraphqlTransforms.TO_JAVA, value }); - - return result; }, []); return ( diff --git a/pages/graphql-to-schema-ast.tsx b/pages/graphql-to-schema-ast.tsx index d3792a0..0131e64 100644 --- a/pages/graphql-to-schema-ast.tsx +++ b/pages/graphql-to-schema-ast.tsx @@ -19,7 +19,8 @@ export default function() { const result = await graphqlWorker.send({ type: GraphqlTransforms.TO_SCHEMA_AST, - value + value, + extension: "graphql" }); return prettierWorker.send({ diff --git a/pages/graphql-to-typescript-mongodb.tsx b/pages/graphql-to-typescript-mongodb.tsx index ae087d8..e81e444 100644 --- a/pages/graphql-to-typescript-mongodb.tsx +++ b/pages/graphql-to-typescript-mongodb.tsx @@ -19,7 +19,8 @@ export default function() { const result = await graphqlWorker.send({ type: GraphqlTransforms.TO_TYPESCRIPT_MONGODB, - value + value, + extension: "ts" }); return prettierWorker.send({ diff --git a/workers/graphql.worker.ts b/workers/graphql.worker.ts index a9aea71..14ec870 100644 --- a/workers/graphql.worker.ts +++ b/workers/graphql.worker.ts @@ -54,7 +54,7 @@ function getPlugins(type: GraphqlTransforms) { } _self.onmessage = async ({ data: { id, payload } }) => { - const { value, document = "", type } = payload; + const { value, document = "", type, extension = "tsx" } = payload; try { const plugins = getPlugins(type); @@ -66,7 +66,7 @@ _self.onmessage = async ({ data: { id, payload } }) => { }); const result = await codegen({ - filename: "a.tsx", + filename: `a.${extension}`, schema: parse(value), // @ts-ignore plugins: plugins.map((_plugin, i) => ({