You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to integrate Pothos GraphQL into nitro as a module.
However, I am unsure how to develop a module with build stage (with vfs) to build a single entrypoint (under /graphql). Similar to how nitro build the API/routes folder into a single entrypoint (nitro instance).
So far what I've done:
In the module, I append auto import to include /graphql folder.
In the module init stage (module function), it will create a virtual file containing all the paths and import function for graphQL server object definition (by looking at the filename postfix).
A util script to import and execute all the definition code from this virtual files.
A routes/graphql.ts file running the util script to build (and reuse) the graphQL server instance.
However, it cannot import any of the virtual file built by the module, it would have the error:
[plugin node-resolve] Could not resolve import "#nitro-graphql-server" in ../nitro-graphql-server/examples/nitro/server/graphql/queries/get-animals.schema.ts using imports defined in ../nitro-graphql-server/examples/nitro/package.json.
[plugin node-resolve] Could not resolve import "#nitro-graphql-server" in ../nitro-graphql-server/examples/nitro/server/graphql/mutations/create-animal.schema.ts using imports defined in ../nitro-graphql-server/examples/nitro/package.json.
[plugin node-resolve] Could not resolve import "#nitro-graphql-server" in ../nitro-graphql-server/examples/nitro/server/graphql/queries/get-animals.schema.ts using imports defined in ../nitro-graphql-server/examples/nitro/package.json.
"#nitro-graphql-server" is imported by "server/graphql/queries/get-animals.schema.ts", but could not be resolved – treating it as an external dependency.
[plugin node-resolve] Could not resolve import "#nitro-graphql-server" in ../nitro-graphql-server/examples/nitro/server/graphql/mutations/create-animal.schema.ts using imports defined in ../nitro-graphql-server/examples/nitro/package.json.
"#nitro-graphql-server" is imported by "server/graphql/mutations/create-animal.schema.ts", but could not be resolved – treating it as an external dependency.
✔ Nitro Server built in 517 ms nitro 4:54:01 PM
[worker reload] TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier "#nitro-graphql-server" is not defined in package ../nitro-graphql-server/examples/nitro/package.json imported from ../nitro-graphql-server/examples/nitro/.nitro/dev/index.mjs
I'm unsure if the process is correct, would greatly appreciate if someone could provide guidance on how to write a module with auto import feature and building an object instance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to integrate Pothos GraphQL into nitro as a module.
However, I am unsure how to develop a module with build stage (with vfs) to build a single entrypoint (under
/graphql). Similar to how nitro build the API/routes folder into a single entrypoint (nitro instance).So far what I've done:
/graphqlfolder.routes/graphql.tsfile running the util script to build (and reuse) the graphQL server instance.However, it cannot import any of the virtual file built by the module, it would have the error:
I'm unsure if the process is correct, would greatly appreciate if someone could provide guidance on how to write a module with auto import feature and building an object instance.
Beta Was this translation helpful? Give feedback.
All reactions