• Kris Shinn's avatar
    GraphQL master FF for review (#18445) · f91312db
    Kris Shinn authored
    * Initial work on a graphql API
    
    * Added receipts, and more transaction fields.
    
    * Finish receipts, add logs
    
    * Add transactionCount to block
    
    * Add types  and .
    
    * Update Block type to be compatible with ethql
    
    * Rename nonce to transactionCount in Account, to be compatible with ethql
    
    * Update transaction, receipt and log to match ethql
    
    * Add  query operator, for a range of blocks
    
    * Added ommerCount to Block
    
    * Add transactionAt and ommerAt to Block
    
    * Added sendRawTransaction mutation
    
    * Add Call and EstimateGas to graphQL API
    
    * Refactored to use hexutil.Bytes instead of HexBytes
    
    * Replace BigNum with hexutil.Big
    
    * Refactor call and estimateGas to use ethapi struct type
    
    * Replace ethgraphql.Address with common.Address
    
    * Replace ethgraphql.Hash with common.Hash
    
    * Converted most quantities to Long instead of Int
    
    * Add support for logs
    
    * Fix bug in runFilter
    
    * Restructured Transaction to work primarily with headers, so uncle data is reported properly
    
    * Add gasPrice API
    
    * Add protocolVersion API
    
    * Add syncing API
    
    * Moved schema into its own source file
    
    * Move some single use args types into anonymous structs
    
    * Add doc-comments
    
    * Fixed backend fetching to use context
    
    * Added (very) basic tests
    
    * Add documentation to the graphql schema
    
    * Fix reversion for formatting of big numbers
    
    * Correct spelling error
    
    * s/BigInt/Long/
    
    * Update common/types.go
    
    * Fixes in response to review
    
    * Fix lint error
    
    * Updated calls on private functions
    
    * Fix typo in graphql.go
    
    * Rollback ethapi breaking changes for graphql support
    Co-Authored-By: 's avatarArachnid <arachnid@notdot.net>
    f91312db
meta.go 1.3 KB
package resolvable

import (
	"fmt"
	"reflect"

	"github.com/graph-gophers/graphql-go/internal/common"
	"github.com/graph-gophers/graphql-go/internal/schema"
	"github.com/graph-gophers/graphql-go/introspection"
)

var MetaSchema *Object
var MetaType *Object

func init() {
	var err error
	b := newBuilder(schema.Meta)

	metaSchema := schema.Meta.Types["__Schema"].(*schema.Object)
	MetaSchema, err = b.makeObjectExec(metaSchema.Name, metaSchema.Fields, nil, false, reflect.TypeOf(&introspection.Schema{}))
	if err != nil {
		panic(err)
	}

	metaType := schema.Meta.Types["__Type"].(*schema.Object)
	MetaType, err = b.makeObjectExec(metaType.Name, metaType.Fields, nil, false, reflect.TypeOf(&introspection.Type{}))
	if err != nil {
		panic(err)
	}

	if err := b.finish(); err != nil {
		panic(err)
	}
}

var MetaFieldTypename = Field{
	Field: schema.Field{
		Name: "__typename",
		Type: &common.NonNull{OfType: schema.Meta.Types["String"]},
	},
	TraceLabel: fmt.Sprintf("GraphQL field: __typename"),
}

var MetaFieldSchema = Field{
	Field: schema.Field{
		Name: "__schema",
		Type: schema.Meta.Types["__Schema"],
	},
	TraceLabel: fmt.Sprintf("GraphQL field: __schema"),
}

var MetaFieldType = Field{
	Field: schema.Field{
		Name: "__type",
		Type: schema.Meta.Types["__Type"],
	},
	TraceLabel: fmt.Sprintf("GraphQL field: __type"),
}