Skip to content

Plugins support #390

@bc-tayvs

Description

@bc-tayvs

Is your feature request related to a problem? Please describe.
Currently, field descriptions from the GraphQL schema are discarded during code generation, and there is no way to retain or access them. Schema generation tools that use field tags to provide additional context can benefit from keeping the descriptions

Describe the solution you'd like
Introduce a new plugins section in the genqlient.yaml configuration file. This section would allow users to define custom plugins for field tags. Each plugin would specify:

  • A name for the tag.
  • A path to a shared object file implementing the plugin.

The plugin function should have the following signature (not final):

type PluginInput struct {
	GraphQLName string
	Description string
}

// The function can 
// - return error if something goes wrong. this will stop generation
// - return not Nil result in success case
// - return Nil as a result if the tag should be skipped for provided input
func FieldTagPlugin(input generate.PluginInput) (*string, error) {
  // Implementation.
}

Configuration example:

plugins:
  field_tags: #called field_tags to leave place for other potential plugins
    - name: jsonschema
      path: plugins/jsonschema.so

Describe alternatives you've considered

Additional context
More details about my case.

I have a model generated by the genqclient tool. And I need of schema for it. For this another tool is used, but without descriptions some context is missed. Tool that generates schemas can add descriptions if they store in a particular tag. So i'm trying to connect two tools together.

I already have created and tested a draft PR with the solution: #389

Still need to take care of tests. But some initial review/feedback would be helpful

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions