Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

inferSchema shouldn't generate types that begin with non-alphanumeric characters #427

Closed
johnymontana opened this issue May 5, 2020 · 4 comments

Comments

@johnymontana
Copy link
Contributor

johnymontana commented May 5, 2020

Neo4j node labels can begin with non-alphanumeric characters (such as _). Currently the inferSchema process creates a GraphQL type for these node labels with the same name.

In the case where we have a Neo4j node label such as _Bloom_Perspective inferSchema should not create a GraphQL type that violates this requirement of the GraphQL specification. For example, the following type is problematic because the associated input types will follow the convention of prepending the type name with _ will generate __Bloom_Perspective_Input

type _Bloom_Perspective_ {
   _id: Long!
   data: String!
   id: String!
   name: String!
   roles: [String]!
   version: String!
}

Would it make sense for the inferSchema process to ignore any node labels that begin with the _ character as this is likely to be metadata and not relevant for the GraphQL API?

@Phylodome
Copy link

Would this mean that all generated types would drop the "_" prefix?

That would be very helpful in a couple use cases of my own, where the underscore prefix creates issues with other codegen libraries I'd like to use in combination w/ this one.

Or, alternatively, the capacity to specify a prefix other than underscore for generated types.

@Phylodome
Copy link

Phylodome commented May 13, 2020

@johnymontana Any thoughts on the above? If it's the case that future version of this lib will / could generate types w/o the leading underscore, that would be an extremely useful feature.

@johnymontana
Copy link
Contributor Author

@Phylodome I was thinking of just ignoring any node labels that begin with _ in the inferSchema process since these are like meta nodes that we don't want to include in the GraphQL schema.

The example here was handling nodes added by Neo4j Bloom that define the perspective - metadata specific to the Neo4j Bloom application and not something that should be exposed in the GraphQL API.

Allowing more flexible naming conventions for the generated input types is an interesting idea, but I think is beyond the scope of this specific problem relating to inferSchema.

I'd like to learn more about the issues you're having with other codegen libraries. Could you create another issue with some examples of the problems you have there?

@Phylodome
Copy link

No problem. I detailed the issue in #437. If you'd like more information let me know, but the fundamental issue is pretty simple.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants