reason-react-apollo icon indicating copy to clipboard operation
reason-react-apollo copied to clipboard

Auto-generated Types w/ Non-standard Naming

Open Phylodome opened this issue 5 years ago • 1 comments

When I attempt to run the codegen, I get:

  ✔ Parse configuration
  ❯ Generate outputs
    ❯ Generate src/types/Graphql.re
      ✔ Load GraphQL schemas
      ✔ Load GraphQL documents
      ✖ Generate
        → Module names must start with an uppercase letter.
    ✔ Generate src/types/Apollo.re

I'm pretty sure this is due to the fact that the codegen is attempting to create a module using type names that are auto-generated by neo4j-graphql-js, some of which begin w/ an underscore.

For example:

type _AddArtifactAttractorPayload {
  from: Attractor
  to: Artifact
}

Of course, direct conversion of these type names into module names doesn't play nicely w/ Ocaml's module naming conventions.

Would it be possible to allow users of this lib to specify a prefix regex to strip from module names, or some kind of transform function through which to run type names when converting them to modules?

Phylodome avatar Nov 28 '19 00:11 Phylodome

Just tried to bypass this via direct removal of the leading underscores in the generated introspection query, just to see if I could make some progress, then ran into:

  ✔ Parse configuration
  ❯ Generate outputs
    ❯ Generate src/types/Graphql.re
      ✔ Load GraphQL schemas
      ✔ Load GraphQL documents
      ✖ Generate
        → 1685: <syntax error>
    ✔ Generate src/types/Apollo.re


 Found 1 error

  ✖ src/types/Graphql.re

But because the lib doesn't seem to keep the generated file around if it errors out, this syntax error is entirely opaque to me 😢

Phylodome avatar Nov 28 '19 01:11 Phylodome