Generate custom struct tags
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 143
- Avg merge
- 4h 50m
- Merged PRs (30d)
- 1
Description
**Is your feature request related to a problem? Please describe.**
I would like to generate types from a graphql schema with [neo4j graphql directives](https://neo4j.com/docs/graphql-manual/current/directives/), and convert those to [gogm](https://github.com/mindstand/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:
```graphql
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:
```golang
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
Contributor guide
Research direction
Start by tracing the Go code-generation entry point that converts the example GraphQL schema into structs, then inspect how fields and directives are currently handled. Use the @id and @relationship examples to define the required gogm tags and a configuration or annotation path for custom directives. Done means generated ResourceEntity and Resource types contain the expected tags, with coverage for both directive forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100