dgs-codegen icon indicating copy to clipboard operation
dgs-codegen copied to clipboard

generateJava fails while .graphqlconfig is present in the schema dir

Open mamuf opened this issue 3 years ago • 2 comments

It seems the plugin simply concatenates all files inside the schema dir(s) and then tries to parse them. Why would it do so? Why does it include the .graphqlconfig file as well? There doesn't seem to be any option to exclude some files from the schema paths, unfortunatelly.

Execution failed for task ':app:generateJava'.
> Unable to parse the schema...
  Invalid Syntax : offending token '"schemaPath"' at line 2 column 3

Then it prints the whole schema and apparently the contents of .graphqlconfig is part of it:

  {
    "schemaPath": "schema.graphql"
  }

mamuf avatar Feb 17 '23 14:02 mamuf

Thanks for reporting the issue. We will fix this in an upcoming release.

On Fri, Feb 17, 2023 at 6:48 AM Adam Hošek @.***> wrote:

It seems the plugin simply concatenates all files inside the schema dir(s) and then tries to parse them. Why would it do so? Why does it include the .graphqlconfig file as well? There doesn't seem to be any option to exclude some files from the schema paths, unfortunatelly.

Execution failed for task ':app:generateJava'.

Unable to parse the schema... Invalid Syntax : offending token '"schemaPath"' at line 2 column 3

Then it prints the whole schema and apparently the contents of .graphqlconfig is part of it:

{ "schemaPath": "schema.graphql" }

— Reply to this email directly, view it on GitHub https://github.com/Netflix/dgs-codegen/issues/524, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5JPXN5OQVIF2KXETCDDWLWX6FUTANCNFSM6AAAAAAU7QQDMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

srinivasankavitha avatar Feb 17 '23 15:02 srinivasankavitha

Parameter schemaPaths accepts list of files/paths and I'm pretty sure this issue is no longer valid. Certainly you can do something like this:

schemaPaths = File("${projectDir}/src/main/resources/schema/").walkTopDown()
            .filter { it.name.endsWith(".graphqls") }
            .map { it.path }.toMutableList()

dwilkolek avatar Apr 19 '24 19:04 dwilkolek