Esempio n. 1
0
package execution

import (
	"errors"
	"fmt"
	"reflect"
	"sync"

	debug "github.com/ng-vu/graphql-go/internal/debug"
	lang "github.com/ng-vu/graphql-go/internal/language"
	typs "github.com/ng-vu/graphql-go/internal/types"
)

var LOG = debug.New("graphql/execution")

type _Context struct {
	Schema         typs.QLSchema
	Fragments      map[string]*lang.FragmentDefinition
	RootValue      interface{}
	Operation      *lang.OperationDefinition
	VariableValues map[string]interface{}
	Errors         []error
}

type Result struct {
	Data   interface{}
	Errors []error
}

type Options struct {
	RootValue      interface{}
Esempio n. 2
0
package language

import (
	"fmt"
	"regexp"
	"strconv"

	"github.com/ng-vu/graphql-go/internal/debug"
)

var LOG = debug.New("language")

type QLError struct {
	Message   string
	Stack     string
	Nodes     []INode
	Source    *Source
	Positions []int
	Locations []SourceLocation
}

func NewQLError(message string, nodes []INode) QLError {
	return NewQLErrorWithSource(message, nodes, "", nil, nil)
}

func NewQLErrorWithSource(message string, nodes []INode, stack string, source *Source, positions []int) QLError {
	err := QLError{
		Message:   message,
		Stack:     stack,
		Nodes:     nodes,
		Source:    source,
Esempio n. 3
0
package graphql

import (
	"fmt"
	"reflect"

	"github.com/ng-vu/graphql-go/internal/debug"
	"github.com/ng-vu/graphql-go/internal/execution"
	"github.com/ng-vu/graphql-go/internal/language"
	"github.com/ng-vu/graphql-go/internal/types"
	"github.com/ng-vu/graphql-go/internal/validation"
	"github.com/ng-vu/graphql-go/ql"
)

var LOG = debug.New("graphql")

type RequestOpts struct {
	RootValue      interface{}
	VariableValues map[string]interface{}
	OperationName  string
}

type Schema struct {
	schema types.QLSchema
}

func NewSchema(query ql.Object, mutations ...ql.Object) (Schema, error) {
	if len(mutations) > 1 {
		panic("graphql: must provide only one mutation object")
	}
	var mutation *ql.Object