Cannot load just subscriptions without queries nor mutations #1634
Closed
teixeirafrancisca
started this conversation in
General
Replies: 1 comment
-
This is |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
When running a separate WebSocket (ws) instance from the main application, TypeGraphQL fails to function correctly with the error message "Query must define one or more fields."
To Reproduce
Ensure that only subscriptions are loaded into this WebSocket instance, with no queries or mutations.
Attempt to use TypeGraphQL in this configuration, such as defining GraphQL schema with TypeGraphQL decorators.
Observe the error "Query must define one or more fields.
Expected Behavior
TypeGraphQL should work correctly even when only subscriptions are loaded. It should not throw errors related to missing query fields when queries and mutations are not expected to be used in this instance.
Logs
{
"message": "Some errors occurred while generating GraphQL schema:
Type Query must define one or more fields.
Please check the
details
property of the error to get more detailed info.","name": "Error",
"stack": "Please check the
details
property of the error to get more detailed info.SchemaGenerator.generateFromMetadata (node_modules/type-graphql/build/cjs/schema/schema-generator.js:36:23)
buildSchema (node_modules/type-graphql/build/cjs/utils/buildSchema.js:29:55)
buildTypeDefsAndResolvers (node_modules/type-graphql/build/cjs/utils/buildTypeDefsAndResolvers.js:13:56)
}
Environment (please complete the following information):
Additional Context
The issue occurs specifically when TypeGraphQL is used with a separate WebSocket instance where only subscriptions are loaded. The error suggests that TypeGraphQL expects queries to be defined even though they are not intended to be used in that context. This behavior is unexpected and hinders the use of TypeGraphQL in certain setups where queries and mutations are not applicable.
To overcome the issue we are loading one query and one mutation.
Code and hack to make it work:
Beta Was this translation helpful? Give feedback.
All reactions