How can I bundle a GraphQL schema? #6873
-
I'm trying to bundle a GraphQL schema as a string, to provide it to a GraphiQL component. I simply tried: import schemaSdl from "./schema.docs.graphql";
@parcel/transformer-graphql: Only executable definitions are supported in GraphQL Documents. Why does it matter if the definition is executable? The documentation on importing GraphQL says that the document is returned as a string. So I try to load the data via const schemaSdl = fs.readFileSync(path.resolve(__dirname, "./docs.graphql.schema"), "utf8"); The documentation on fs.readFileSync calls says that these will be inlined as strings for browser targets. But when I load the bundled application, I get a What is the right method to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
The docs don't say this explicitly, but you need to use |
Beta Was this translation helpful? Give feedback.
-
Same question regarding the error:
why does it matter if the definition is executable? I want to be able to export typeDefs for use by other packages/apps. |
Beta Was this translation helpful? Give feedback.
-
I am also facing the same error. I am trying to migrate my project from webpack to Parcel 2, but stuck with this error! |
Beta Was this translation helpful? Give feedback.
The docs don't say this explicitly, but you need to use
fs.readFileSync(path.join(__dirname, "something"), "utf8)
instead.