schema

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package schema can be used to generate a GraphQL schema (as a string) from Go structure(s) representing the GraphQL query (and mutation and subscription) entry points. This goes hand-in-hand with the "handler" which uses instantiations of those same structures to fulfill the query (mutation/subscription).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(rawEnums map[string][]string, qms ...interface{}) (string, error)

Build generates a string containing a GraphQL schema.

  • rawEnums: map of enums where each map entry is a slice of strings - each string (incl. map keys) is a name opt. followed by hash (#) and a description. It can be nil if no enums are supplied.
  • 2nd, 3rd and 4th parameters represent the root query, mutation and subscription and *must* be structs (or nil). Each struct is scanned for exported fields to be used to generate the query fields. Any of the 3 can be nil if not implemented, but you must supply at least one.

func MustBuild

func MustBuild(qms ...interface{}) string

MustBuild calls Build but panics on error It takes an (optional) map of enums followed by (up to) 3 root objects (query, mutation, subscription)

Types

type EntryPoint

type EntryPoint int

EntryPoint is an "enumeration" for the 3 different types of GraphQL entry point (query, mutation, subscription)

const (
	Query EntryPoint = iota
	Mutation
	Subscription
)

Jump to

Keyboard shortcuts

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