graph

package module
v0.0.0-...-c983b52 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_LIMIT_VALUE int = 10
	DEFAULT_PAGE_VALUE  int = 0
)

Variables

View Source
var (
	LabelInputConfig = graphql.InputObjectFieldConfig{
		Type:         graphql.String,
		DefaultValue: "",
		Description:  "The display text that will be tagged with a label",
	}
	FieldSetInputInputConfig = graphql.NewInputObject(graphql.InputObjectConfig{
		Name: "FieldSetInputInput",
		Fields: graphql.InputObjectConfigFieldMap{
			"label": &LabelInputConfig,
			"type": &graphql.InputObjectFieldConfig{
				Type:         InputTypeEnum,
				DefaultValue: "text",
				Description:  "The type of input the user will see such as phone, email, calendar, select, text, etc.",
			},
			"minLength": &graphql.InputObjectFieldConfig{
				Type:         graphql.Int,
				DefaultValue: nil,
				Description:  "The minimum number of characters required for the field. See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#maxlength for valid input types",
			},
			"maxLength": &graphql.InputObjectFieldConfig{
				Type:         graphql.Int,
				DefaultValue: nil,
				Description:  "The maximum number of characters required for the field. See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#maxlength for valid input types",
			},
			"min": &graphql.InputObjectFieldConfig{
				Type:         graphql.String,
				DefaultValue: nil,
				Description:  "Minimum value that can be applied to the input. See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/min for valid input types",
			},
			"max": &graphql.InputObjectFieldConfig{
				Type:         graphql.String,
				DefaultValue: nil,
				Description:  "Maximum value that can be applied to the input. See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/max for valid input types",
			},
			"required": &graphql.InputObjectFieldConfig{
				Type:         graphql.Boolean,
				DefaultValue: false,
				Description:  "True if the field is required to be filled out, else false",
			},
			"list": &graphql.InputObjectFieldConfig{
				Type:         graphql.NewList(graphql.String),
				Description:  "List of selectable options. See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#list for valid input types",
				DefaultValue: []string{},
			},
			"multiple": &graphql.InputObjectFieldConfig{
				Type:         graphql.Boolean,
				Description:  "Flag indicating that a user can select multiple values for a input field. See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/multiple for valid input types",
				DefaultValue: false,
			},
		},
	})
	CreateNewFormArgument = graphql.FieldConfigArgument{
		"name": &graphql.ArgumentConfig{
			Type:        graphql.NewNonNull(graphql.String),
			Description: "A unique human readable name for the form",
		},
		"active": &graphql.ArgumentConfig{
			Type:        graphql.NewNonNull(graphql.Boolean),
			Description: "Whether the form is active or usable",
		},
		"fieldsets": &graphql.ArgumentConfig{
			Type: graphql.NewList(graphql.NewInputObject(graphql.InputObjectConfig{
				Name:        "FieldSetInput",
				Description: "Field set to naturally group a number of input fields such as physical mailing address",
				Fields: graphql.InputObjectConfigFieldMap{
					"legend": &graphql.InputObjectFieldConfig{
						Type:         graphql.String,
						DefaultValue: "Provides a description for the form input grouping",
					},
					"inputs": &graphql.InputObjectFieldConfig{
						Type:         graphql.NewList(FieldSetInputInputConfig),
						Description:  "Input Field Configurations",
						DefaultValue: nil,
					},
				},
			})),
		},
	}
)
View Source
var (
	LabelPositionEnum = graphql.NewEnum(graphql.EnumConfig{
		Name: "LabelPositionEnum",
		Values: graphql.EnumValueConfigMap{
			"left":   &graphql.EnumValueConfig{Value: "left"},
			"top":    &graphql.EnumValueConfig{Value: "top"},
			"right":  &graphql.EnumValueConfig{Value: "right"},
			"bottom": &graphql.EnumValueConfig{Value: "bottom"},
		},
	})
	InputTypeEnum = graphql.NewEnum(graphql.EnumConfig{
		Name: "FieldType",
		Values: graphql.EnumValueConfigMap{
			"button":         &graphql.EnumValueConfig{Value: "button"},
			"checkbox":       &graphql.EnumValueConfig{Value: "checkbox"},
			"color":          &graphql.EnumValueConfig{Value: "color"},
			"date":           &graphql.EnumValueConfig{Value: "date"},
			"datetime_local": &graphql.EnumValueConfig{Value: "datetime-local"},
			"email":          &graphql.EnumValueConfig{Value: "email"},
			"file":           &graphql.EnumValueConfig{Value: "file"},
			"hidden":         &graphql.EnumValueConfig{Value: "hidden"},
			"image":          &graphql.EnumValueConfig{Value: "image"},
			"month":          &graphql.EnumValueConfig{Value: "month"},
			"number":         &graphql.EnumValueConfig{Value: "number"},
			"password":       &graphql.EnumValueConfig{Value: "password"},
			"radio":          &graphql.EnumValueConfig{Value: "radio"},
			"range":          &graphql.EnumValueConfig{Value: "range"},
			"reset":          &graphql.EnumValueConfig{Value: "reset"},
			"search":         &graphql.EnumValueConfig{Value: "search"},
			"submit":         &graphql.EnumValueConfig{Value: "submit"},
			"tel":            &graphql.EnumValueConfig{Value: "tel"},
			"text":           &graphql.EnumValueConfig{Value: "text"},
			"time":           &graphql.EnumValueConfig{Value: "time"},
			"url":            &graphql.EnumValueConfig{Value: "url"},
			"week":           &graphql.EnumValueConfig{Value: "week"},
		},
	})
)
View Source
var (
	FieldObject = graphql.NewObject(graphql.ObjectConfig{
		Name:        "Field",
		Description: "A generic form field",
		Fields: graphql.Fields{
			"name": &graphql.Field{
				Type:        graphql.NewNonNull(graphql.String),
				Description: "Unique field name for a form",
			},
			"type": &graphql.Field{
				Type: InputTypeEnum,
			},
			"ordinal": &graphql.Field{
				Type:        graphql.NewNonNull(graphql.Int),
				Description: "Order for 0 to N where 0 is showing first, and N is showing last",
			},
		},
	})
	TextFieldObject = graphql.NewObject(graphql.ObjectConfig{
		Name:        "SimpleInputTextField",
		Description: "A simple text field for users to type in single line text",
		Fields: graphql.Fields{
			"name": &graphql.Field{
				Type:        graphql.NewNonNull(graphql.String),
				Description: "Unique field name for a form",
			},
			"type": &graphql.Field{
				Type: InputTypeEnum,
			},
			"ordinal": &graphql.Field{
				Type:        graphql.NewNonNull(graphql.Int),
				Description: "Order for 0 to N where 0 is showing first, and N is showing last",
			},
			"placeholder": &graphql.Field{
				Type:        graphql.String,
				Description: "Placeholder text to display to user",
			},
			"label": &graphql.Field{
				Type:        graphql.NewNonNull(graphql.String),
				Description: "Label to display next to input",
			},
			"labelPosition": &graphql.Field{
				Type:        LabelPositionEnum,
				Description: "Placement of where the label should be relative to the input field. Default left",
			},
		},
	})
	FieldSetObject = graphql.NewObject(graphql.ObjectConfig{
		Name:        "FieldSet",
		Description: "A grouping of fields within a form",
		Fields: graphql.Fields{
			"legend": &graphql.Field{
				Type:        graphql.NewNonNull(graphql.String),
				Description: "Grouping heading that should be unique on the form",
			},
			"fields": &graphql.Field{
				Type: graphql.NewList(FieldObject),
			},
		},
	})
	FormObject = graphql.NewObject(graphql.ObjectConfig{
		Name:        "Form",
		Description: "Dynamic Form with groups or fields",
		Fields: graphql.Fields{
			"id": &graphql.Field{
				Type: graphql.NewNonNull(graphql.String),
			},
			"name": &graphql.Field{
				Type:        graphql.NewNonNull(graphql.String),
				Description: "Unique form name that should be human readable",
			},
			"fieldsets": &graphql.Field{
				Type: graphql.NewList(FieldSetObject),
			},
		},
	})
)
View Source
var (
	CreateFormMutation = graphql.NewObject(graphql.ObjectConfig{
		Name:        "CreateFormMutation",
		Description: "Create a brand new form",
		Fields: graphql.Fields{
			"create": &graphql.Field{
				Args:        CreateNewFormArgument,
				Description: "Create a new form",
				Type: graphql.NewObject(graphql.ObjectConfig{
					Name: "CreateNewFormResponse",
					Fields: graphql.Fields{
						"id": &graphql.Field{
							Type: graphql.NewNonNull(graphql.String),
						},
					},
				}),
				Resolve: createFormResolver,
			},
		},
	})
)
View Source
var (
	FormQueries = graphql.NewObject(graphql.ObjectConfig{
		Name: "FormsQueries",
		Fields: graphql.Fields{
			"list": &graphql.Field{
				Type: graphql.NewObject(graphql.ObjectConfig{
					Name: "FormList",
					Fields: graphql.Fields{
						"results": &graphql.Field{
							Type: graphql.NewList(FormObject),
						},
						"count": &graphql.Field{
							Type: graphql.Int,
						},
					},
				}),
				Args: graphql.FieldConfigArgument{
					"id": &graphql.ArgumentConfig{
						DefaultValue: nil,
						Type:         graphql.String,
					},
					"name": &graphql.ArgumentConfig{
						DefaultValue: nil,
						Type:         graphql.String,
					},
					"limit": &graphql.ArgumentConfig{
						DefaultValue: 10,
						Description:  "Total number records to retreive and skip per page",
						Type:         graphql.Int,
					},
					"page": &graphql.ArgumentConfig{
						DefaultValue: 0,
						Description:  "Number of pages to skip before retreiving records",
						Type:         graphql.Int,
					},
				},
				Resolve: formListResolver,
			},
		},
	})
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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