DataSQRL / sqrl

Flexible development framework for building streaming data applications in SQL with Kafka, Flink, Postgres, GraphQL, and more.
https://www.datasqrl.com/
98 stars 14 forks source link

Allow GraphQL schemas without Query type #280

Open mbroecheler opened 1 year ago

mbroecheler commented 1 year ago

Right now, the compiler and servlet expect a query type and at least one field inside the type in order to run. This means users cannot define a schema that only accepts mutations.

deploy-servlet-1              | 16:48:07.819 [vert.x-eventloop-thread-0] ERROR io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer - Failed in deploying verticle
deploy-servlet-1              | graphql.schema.validation.InvalidSchemaException: invalid schema:
deploy-servlet-1              | "Query" must define one or more fields.
deploy-servlet-1              |     at graphql.schema.GraphQLSchema$Builder.validateSchema(GraphQLSchema.java:935) ~[vertx-server.jar:?]
deploy-servlet-1              |     at graphql.schema.GraphQLSchema$Builder.buildImpl(GraphQLSchema.java:929) ~[vertx-server.jar:?]
deploy-servlet-1              |     at graphql.schema.GraphQLSchema$Builder.build(GraphQLSchema.java:894) ~[vertx-server.jar:?]
deploy-servlet-1              |     at graphql.schema.idl.SchemaGenerator.makeExecutableSchemaImpl(SchemaGenerator.java:117) ~[vertx-server.jar:?]
deploy-servlet-1              |     at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:87) ~[vertx-server.jar:?]
deploy-servlet-1              |     at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:58) ~[vertx-server.jar:?]
deploy-servlet-1              |     at com.datasqrl.graphql.server.BuildGraphQLEngine.visitRoot(BuildGraphQLEngine.java:83) ~[vertx-server.jar:?]
deploy-servlet-1              |     at com.datasqrl.graphql.server.BuildGraphQLEngine.visitRoot(BuildGraphQLEngine.java:47) ~[vertx-server.jar:?]
deploy-servlet-1              |     at com.datasqrl.graphql.server.Model$RootGraphqlModel.accept(Model.java:53) ~[vertx-server.jar:?]
deploy-servlet-1              |     at com.datasqrl.graphql.GraphQLServer.createGraphQL(GraphQLServer.java:154) ~[vertx-server.jar:?]
deploy-servlet-1              |     at com.datasqrl.graphql.GraphQLServer.start(GraphQLServer.java:102) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$5(DeploymentManager.java:196) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:264) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:246) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:43) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[vertx-server.jar:?]
deploy-servlet-1              |     at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[vertx-server.jar:?]
deploy-servlet-1              |     at java.lang.Thread.run(Thread.java:829) ~[?:?]
henneberger commented 1 year ago

Would love to except it is against the graphql spec. We'd have to put in a no-op function as a placeholder.

https://spec.graphql.org/June2018/#sec-Root-Operation-Types

The query root operation type must be provided and must be an Object type.

And later

An Object type must define one or more fields
henneberger commented 11 months ago

Fixed in #447

henneberger commented 5 months ago

Reopening. A refactor removed this feature and it needs to be reintroduced.