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

Generate custom struct tags #234

Open
nettrino opened this issue Nov 16, 2022 · 1 comment
Open

Generate custom struct tags #234

nettrino opened this issue Nov 16, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@nettrino
Copy link

Is your feature request related to a problem? Please describe.

I would like to generate types from a graphql schema with neo4j graphql directives, and convert those to gogm-compatible struct tags.

  • The first part of the task is about appending gogm style struct tags for variable names.
  • The second and more complex part of the task is to support custom neo4j directives

For instance:

Example of graphql with neo4j directives:

  interface ResourceEntity {
    id: ID! @id(autogenerate: false)
    name: String
  }
  
  type Resource implements ResourceEntity {
    id: ID! @id(autogenerate: false)
    name: String
    containedBy: [ResourceEntity!]! @relationship(type: "CONTAINS", direction: IN)
  }

Describe the solution you'd like

Example of generated code:

type ResourceEntity struct {
	// provides required node fields
	gogm.BaseNode

    Name         string                `gogm:"name=name"`
}

type Resource struct {
	// provides required node fields
	gogm.BaseNode

	Name  string     `gogm:"name=name"`
	ContainedBy  []*ResourceEntity   `gogm:"direction=incoming;relationship=..."`
}

Would be helpful to even pass a json/yaml or have an annotation-based approach to define struct tags for the different directives

Describe alternatives you've considered
I can manually parse graphql and emit struct_tags of appropriate types for gogm

@nettrino nettrino added the enhancement New feature or request label Nov 16, 2022
@benjaminjkraft
Copy link
Collaborator

Interesting. This looks complex enough I think we'd need to do it as some sort of plugin (or maybe even two, one for neo4j and one for gogm). I've created #237 to track setting up a plugin API; it will require some careful design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants