graphql

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 26 Imported by: 0

README

Ridu GraphQL plugin

plugins/graphql adds an optional, manifest-derived GraphQL transport to a published Ridu application. Applications that do not import this package do not link the GraphQL parser or execution runtime. Resolvers enter the same Local API as REST and the SDK, preserving access, validation, hooks, transactions, localization, population, and redaction.

Install and register

Add the package to an existing Ridu project and register it in the executable Go config:

import (
	"github.com/riducms/ridu"
	graphqlplugin "github.com/riducms/ridu/plugins/graphql"
)

func Config() ridu.Config {
	return ridu.Config{
		Name: "Acme Editorial",
		Plugins: []ridu.Plugin{
			graphqlplugin.New(),
		},
		Collections: []ridu.Collection{Users, Posts},
	}
}

GraphQL has no admin companion package. Finish the integration with the ordinary project checks:

go mod tidy
ridu generate
ridu migrate plan
ridu check
ridu dev

The default endpoint is POST /api/graphql. Enabling the transport alone does not add stored fields or require a migration; create and apply one when the same change also modifies the schema. For deterministic SDL drift checks, configure and commit the generated schema described in the guide.

Verify the outcome

Send an authenticated bounded query to /api/graphql, then verify the same actor receives the same denial and field redaction through REST. Ridu rejects invalid generated names and collisions at startup and applies configurable body, depth, alias, list, variable, and complexity bounds before execution.

GraphQL reads, CRUD, authentication, localization, relationships, globals, drafts, versions, and trash are generated from the resolved manifest. File transfer, scheduling, document locks, bulk operations, and live preview remain REST/SDK-focused workflows.

See the complete GraphQL adoption guide for resource overrides, trusted extensions, committed SDL generation, security limits, examples, and troubleshooting. The Go API reference documents New, Options, and the extension contracts.

Documentation

Overview

Package graphql provides Ridu's optional, manifest-derived GraphQL transport. Applications that do not import this package do not link a GraphQL runtime.

Index

Constants

View Source
const Key = "graphql"

Variables

This section is empty.

Functions

func GenerateSDL

func GenerateSDL(manifest schema.Manifest, options ...Options) (string, error)

GenerateSDL returns the deterministic schema definition for a resolved Ridu manifest. It does not enable network introspection or require a running app.

func New

func New(options ...Options) ridu.Plugin

New enables GraphQL for an application. At most one Options value is used.

Types

type ExtensionContext

type ExtensionContext struct {
	Context         context.Context
	Args            map[string]interface{}
	Info            enginegraphql.ResolveInfo
	Actor           *store.Document
	ActorCollection riduschema.CollectionSlug
	Local           *ridu.LocalAPI
	App             *ridu.App
}

ExtensionContext is scoped to one GraphQL field execution.

type ExtensionField

type ExtensionField struct {
	Name        string
	Description string
	Type        enginegraphql.Output
	Args        enginegraphql.FieldConfigArgument
	Cost        int
	Resolve     ExtensionResolver
}

ExtensionField adds one trusted compiled root field. Resolvers receive the authenticated actor and Ridu's public APIs, not a store adapter.

type ExtensionResolver

type ExtensionResolver func(ExtensionContext) (interface{}, error)

ExtensionResolver executes one custom query or mutation.

type Options

type Options struct {
	Path               string
	MaxBodyBytes       int64
	MaxVariableBytes   int
	MaxDepth           int
	MaxAliases         int
	MaxComplexity      int
	MaxListLimit       int
	AllowIntrospection bool
	// Resources optionally renames or suppresses generated surfaces by
	// collection/global slug. Omitted resources use their manifest labels and
	// expose both queries and mutations.
	Resources       map[string]ResourceOptions
	Queries         []ExtensionField
	Mutations       []ExtensionField
	ValidationRules []enginegraphql.ValidationRuleFn
}

Options controls the exact GraphQL route and resource safeguards. Zero values select secure defaults.

type ResourceOptions

type ResourceOptions struct {
	SingularName     string
	PluralName       string
	DisableQueries   bool
	DisableMutations bool
}

ResourceOptions controls one collection or global's generated GraphQL surface without changing its manifest-owned slug or REST contract.

Jump to

Keyboard shortcuts

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