Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Error for missing empty block #1252

Closed
cornerman opened this issue Jan 12, 2022 · 4 comments · Fixed by #1283
Closed

Parsing Error for missing empty block #1252

cornerman opened this issue Jan 12, 2022 · 4 comments · Fixed by #1283
Labels
bug Something isn't working good first issue Good for newcomers tools Issue related to Caliban tools like code generation or schema comparison

Comments

@cornerman
Copy link
Contributor

We are getting a Parsing Error when generating client code for a graphql schema with the sbt plugin.

Our graphql schema contains the following line:

input foobar

And we get the following error:

Parsing Error: Position 5143:1, found ""
caliban.parsing.Parser$.$anonfun$parseQuery$7(Parser.scala:23)
zio.ZIO$.$anonfun$fail$1(ZIO.scala:2898)
zio.internal.FiberContext.evaluateNow(FiberContext.scala:413)
zio.Runtime.unsafeRunWith(Runtime.scala:221)
zio.Runtime.unsafeRunSync(Runtime.scala:84)
zio.Runtime.unsafeRunSync$(Runtime.scala:81)
zio.Runtime$$anon$3.unsafeRunSync(Runtime.scala:288)
zio.Runtime.unsafeRun(Runtime.scala:59)
zio.Runtime.unsafeRun$(Runtime.scala:58)
zio.Runtime$$anon$3.unsafeRun(Runtime.scala:288)
caliban.codegen.CalibanSourceGenerator$.generateSources$1(CalibanSourceGenerator.scala:122)
caliban.codegen.CalibanSourceGenerator$.$anonfun$apply$35(CalibanSourceGenerator.scala:131)
caliban.codegen.CalibanSourceGenerator$.$anonfun$apply$35$adapted(CalibanSourceGenerator.scala:130)
sbt.util.Tracked$.$anonfun$outputChangedW$1(Tracked.scala:128)
caliban.codegen.CalibanSourceGenerator$.apply(CalibanSourceGenerator.scala:144)
caliban.codegen.CalibanPlugin$.$anonfun$calibanScopedSettings$3(CalibanPlugin.scala:40)
scala.Function1.$anonfun$compose$1(Function1.scala:49)
sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
sbt.std.Transform$$anon$4.work(Transform.scala:68)
sbt.Execute.$anonfun$submit$2(Execute.scala:282)
sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
sbt.Execute.work(Execute.scala:291)
sbt.Execute.$anonfun$submit$1(Execute.scala:282)
sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base/java.lang.Thread.run(Thread.java:831)

We can fix it by rewriting our graphql schema to:

input foobar {}

This also happens for enum foobar without braces.

Our graphql schema was generated from hasura with the following command:

npx --package=graphqurl gq http://localhost:8080/v1/graphql --introspect
@ghostdogpr
Copy link
Owner

That's not valid graphql, is it?

In the spec:

An Input Object type must define one or more input fields.

An Enum type must define one or more unique enum values.

@ghostdogpr
Copy link
Owner

Related code in the parser:

@cornerman
Copy link
Contributor Author

Good point, I do not know. But that is what we get from hasura :)

Mind you, there are normally two schema with hasura. One for authorized users and one unauthorized users. As of now, we get multiple empty inputs and empty enums in the unauthorized case.

I just opened another issue regarding enums here: #1253.

@ghostdogpr
Copy link
Owner

ghostdogpr commented Jan 15, 2022

According to the spec, enum foo and input foo should be supported during parsing. It's not a valid schema so code generation should fail, but it shouldn't fail during parsing.

@ghostdogpr ghostdogpr added bug Something isn't working good first issue Good for newcomers tools Issue related to Caliban tools like code generation or schema comparison labels Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers tools Issue related to Caliban tools like code generation or schema comparison
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants