package playground

import "github.com/99designs/gqlgen/graphql/playground"

Index

Functions

func AltairHandler

func AltairHandler(title, endpoint string, options map[string]any) http.HandlerFunc

AltairHandler responsible for setting up the altair playground

func ApolloSandboxHandler

func ApolloSandboxHandler(title, endpoint string, opts ...ApolloSandboxOption) http.HandlerFunc

ApolloSandboxHandler responsible for setting up the apollo sandbox playground

func Handler

func Handler(title, endpoint string, opts ...GraphiqlConfigOption) http.HandlerFunc

Handler responsible for setting up the playground

func HandlerWithHeaders

func HandlerWithHeaders(
	title, endpoint string,
	fetcherHeaders, uiHeaders map[string]string,
) http.HandlerFunc

HandlerWithHeaders sets up the playground. fetcherHeaders are used by the playground's fetcher instance and will not be visible in the UI. uiHeaders are default headers that will show up in the UI headers editor.

Types

type ApolloSandboxOption

type ApolloSandboxOption func(options *apolloSandboxOptions)

func WithApolloSandboxEndpointIsEditable

func WithApolloSandboxEndpointIsEditable(endpointIsEditable bool) ApolloSandboxOption

WithApolloSandboxEndpointIsEditable By default, the embedded Sandbox has a URL input box that is editable by users.

Set endpointIsEditable to false to prevent users of your embedded Sandbox instance from changing the endpoint URL.

func WithApolloSandboxHideCookieToggle

func WithApolloSandboxHideCookieToggle(hideCookieToggle bool) ApolloSandboxOption

WithApolloSandboxHideCookieToggle By default, the embedded Sandbox does not show the Include cookies toggle in its connection settings.

Set hideCookieToggle to false to enable users of your embedded Sandbox instance to toggle the Include cookies setting.

func WithApolloSandboxInitialStateCollectionIdAndOperationId

func WithApolloSandboxInitialStateCollectionIdAndOperationId(collectionId, operationId string) ApolloSandboxOption

WithApolloSandboxInitialStateCollectionIdAndOperationId The ID of a collection, paired with an operation ID to populate in the Sandbox on load.

You can find these values from a registered graph in Studio by clicking the ... menu next to an operation in the Explorer of that graph and selecting View operation details.

func WithApolloSandboxInitialStateDocument

func WithApolloSandboxInitialStateDocument(document string) ApolloSandboxOption

WithApolloSandboxInitialStateDocument Document operation to populate in the Sandbox's editor on load.

If you omit this, the Sandbox initially loads an example query based on your schema.

func WithApolloSandboxInitialStateHeaders

func WithApolloSandboxInitialStateHeaders(headers map[string]any) ApolloSandboxOption

WithApolloSandboxInitialStateHeaders Headers containing initial variable values to populate in the Sandbox on load.

If provided, these variables should apply to the initial query you provide for document.

func WithApolloSandboxInitialStateIncludeCookies

func WithApolloSandboxInitialStateIncludeCookies(includeCookies bool) ApolloSandboxOption

WithApolloSandboxInitialStateIncludeCookies Set this value to true if you want the Sandbox to pass { credentials: 'include' } for its requests by default.

If you set hideCookieToggle to false, users can override this default setting with the Include cookies toggle. (By default, the embedded Sandbox does not show the Include cookies toggle in its connection settings.)

If you also pass the handleRequest option, this option is ignored.

Read more about the fetch API and credentials here https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials

func WithApolloSandboxInitialStatePollForSchemaUpdates

func WithApolloSandboxInitialStatePollForSchemaUpdates(pollForSchemaUpdates bool) ApolloSandboxOption

WithApolloSandboxInitialStatePollForSchemaUpdates If true, the embedded Sandbox periodically polls your initialEndpoint for schema updates.

The default value is false.

func WithApolloSandboxInitialStateSharedHeaders

func WithApolloSandboxInitialStateSharedHeaders(sharedHeaders map[string]any) ApolloSandboxOption

WithApolloSandboxInitialStateSharedHeaders Headers that are applied by default to every operation executed by the embedded Sandbox.

Users can disable the application of these headers, but they can't modify their values.

The embedded Sandbox always includes these headers in its introspection queries to your initialEndpoint.

func WithApolloSandboxInitialStateVariables

func WithApolloSandboxInitialStateVariables(variables map[string]any) ApolloSandboxOption

WithApolloSandboxInitialStateVariables Variables containing initial variable values to populate in the Sandbox on load.

If provided, these variables should apply to the initial query you provide for document.

type GraphiqlConfig

type GraphiqlConfig struct {
	Title                 string
	StoragePrefix         string
	Endpoint              string
	FetcherHeaders        map[string]string
	UiHeaders             map[string]string
	EndpointIsAbsolute    bool
	SubscriptionEndpoint  string
	Version               string
	EnablePluginExplorer  bool
	PluginExplorerVersion string
	// https://www.jsdelivr.com/package/npm/@graphiql/plugin-explorer?tab=files
	PluginExplorerCssSRI string
	PluginExplorerJsSRI  string
	// https://www.jsdelivr.com/package/npm/graphiql?tab=files
	CssSRI string
	JsSRI  string
	// https://www.jsdelivr.com/package/npm/react?tab=files
	ReactSRI string
	// https://www.jsdelivr.com/package/npm/react-dom?tab=files
	ReactDOMSRI string
}

type GraphiqlConfigOption

type GraphiqlConfigOption func(*GraphiqlConfig)

func WithGraphiqlEnablePluginExplorer

func WithGraphiqlEnablePluginExplorer(enable bool) GraphiqlConfigOption

func WithGraphiqlFetcherHeaders

func WithGraphiqlFetcherHeaders(headers map[string]string) GraphiqlConfigOption

func WithGraphiqlUiHeaders

func WithGraphiqlUiHeaders(headers map[string]string) GraphiqlConfigOption

func WithStoragePrefix

func WithStoragePrefix(prefix string) GraphiqlConfigOption

Source Files

altair_playground.go apollo_sandbox_playground.go playground.go

Version
v0.17.73 (latest)
Published
May 2, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
2 days ago

Tools for package owners.