extfieldgen

package module
v0.0.0-...-67e4548 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 7 Imported by: 0

README

ExtFieldGen

ExtFieldGen is a gqlgen plugin which enables you to specify extra fields with directives.

Usage

package main

import (
    "fmt"
    "os"
    "github.com/99designs/gqlgen/api"
    "github.com/99designs/gqlgen/codegen/config"
    "github.com/Warashi/extfieldgen"
)

func main() {
    cfg, err := config.LoadConfigFromDefaultLocations()
    if err != nil {
        fmt.Fprintln(os.Stderr, "failed to load config", err.Error())
        os.Exit(2)
    }
    if err := api.Generate(cfg, api.PrependPlugin(extfieldgen.New())); err != nil {
        fmt.Fprintln(os.Stderr, err.Error())
        os.Exit(3)
    }
}

Schema Example

type Foo {
  bar: String!
}

type Bar 
  @extraField(name: "FooBar", type: "*Foo")
  @extraField(name: "FooBarBaz", type: "[]*Foo")
  @extraField(name: "RecursiveBar", type: "*Bar")
  @extraField(name: "SomeFieldWithDescription", type: "*Bar", description: "SomeFieldWithDescription is example field")
  @extraField(name: "SomeIntField", type: "int")
  @extraField(name: "OtherPackageType", type: "github.com/you/pkg/model.User")
{
  baz: String!
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBuiltin

func IsBuiltin(t string) bool

func IsFullName

func IsFullName(t string) bool

func MakeType

func MakeType(importPath, t string) string

Types

type Plugin

type Plugin struct{}

func New

func New() Plugin

func (Plugin) MutateConfig

func (Plugin) MutateConfig(cfg *config.Config) error

MutateConfig implements plugin.ConfigMutator

func (Plugin) Name

func (Plugin) Name() string

Name implements plugin.Plugin

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL