graphql

package
v1.65.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Example
package main

import (
	"log"
	"net/http"

	"github.com/graphql-go/graphql"
	"github.com/graphql-go/handler"

	ddgraphql "gopkg.in/DataDog/dd-trace-go.v1/contrib/graphql-go/graphql"
)

func main() {
	schema, err := ddgraphql.NewSchema(graphql.SchemaConfig{
		Query: graphql.NewObject(graphql.ObjectConfig{
			Name: "Query",
			Fields: graphql.Fields{
				"hello": &graphql.Field{
					Name: "hello",
					Type: graphql.NewNonNull(graphql.String),
				},
			},
		}),
	})
	if err != nil {
		panic(err)
	}

	http.Handle("/query", handler.New(&handler.Config{Schema: &schema}))
	log.Fatal(http.ListenAndServe(":8080", nil))

	// then:
	// $ curl -XPOST -d '{"query": "{ hello }"}' localhost:8080/query
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSchema

func NewSchema(config graphql.SchemaConfig, options ...Option) (graphql.Schema, error)

Types

type Option

type Option func(*config)

func WithAnalytics

func WithAnalytics(on bool) Option

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate

func WithAnalyticsRate(rate float64) Option

WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

func WithServiceName

func WithServiceName(name string) Option

WithServiceName sets the given service name for the client.

Jump to

Keyboard shortcuts

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