| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421 | /* * EliasDB * * Copyright 2016 Matthias Ladkau. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */package interpreterimport (	"fmt"	"strings"	"devt.de/krotik/common/lang/graphql/parser")/*ProcessIntrospection filters the full introspection down to the required fields.*/func (rt *selectionSetRuntime) ProcessIntrospection() map[string]interface{} {	return rt.FilterIntrospectionResponse(rt.ProcessFullIntrospection())}/*ProcessFullIntrospection returns the full introspection with all known fields.*/func (rt *selectionSetRuntime) ProcessFullIntrospection() map[string]interface{} {	res := make(map[string]interface{})	fieldMap := rt.GetFields()	for symbol := range fieldMap {		// General types		if symbol == "queryType" {			res["queryType"] = map[string]interface{}{				"name": "Query",			}			if !rt.rtp.readOnly {				res["mutationType"] = map[string]interface{}{					"name": "Mutation",				}			} else {				res["mutationType"] = nil			}			res["subscriptionType"] = map[string]interface{}{				"name": "Subscription",			}		}		if symbol == "types" {			res["types"] = rt.GetTypesIntrospection()		}		if symbol == "directives" {			res["directives"] = rt.GetDirectivesIntrospection()		}	}	return res}func (rt *selectionSetRuntime) FilterIntrospectionResponse(res map[string]interface{}) map[string]interface{} {	filteredRes := make(map[string]interface{})	fieldMap := rt.GetFields()	for symbol, field := range fieldMap {		reschild := res[symbol]		if srt := field.SelectionSetRuntime(); srt != nil {			// Check for list			if reschildList, ok := reschild.([]interface{}); ok {				filterResList := []interface{}{}				for _, reschild := range reschildList {					filterResList = append(filterResList, srt.FilterIntrospectionResponse(reschild.(map[string]interface{})))				}				filteredRes[symbol] = filterResList			} else if reschildMap, ok := reschild.(map[string]interface{}); ok {				filteredRes[symbol] = srt.FilterIntrospectionResponse(reschildMap)			} else {				filteredRes[symbol] = reschild			}		} else {			filteredRes[symbol] = reschild		}	}	return filteredRes}/*GetTypesIntrospection returns the introspection for all available types.*/func (rt *selectionSetRuntime) GetTypesIntrospection() interface{} {	res := make([]interface{}, 0)	queryType := map[string]interface{}{		"kind":          "OBJECT",		"name":          "Query",		"description":   "Entry point for single read queryies.",		"fields":        rt.GetFieldTypesIntrospection("Lookup", true),		"inputFields":   nil,		"interfaces":    []interface{}{},		"enumValues":    nil,		"possibleTypes": nil,	}	res = append(res, queryType)	if !rt.rtp.readOnly {		mutationType := map[string]interface{}{			"kind":          "OBJECT",			"name":          "Mutation",			"description":   "Entry point for writing queryies.",			"fields":        rt.GetFieldTypesIntrospection("Insert or modify", false),			"inputFields":   nil,			"interfaces":    []interface{}{},			"enumValues":    nil,			"possibleTypes": nil,		}		res = append(res, mutationType)	}	subscriptionType := map[string]interface{}{		"kind":          "OBJECT",		"name":          "Subscription",		"description":   "Entry point for subscriptions.",		"fields":        rt.GetFieldTypesIntrospection("Subscribe to", true),		"inputFields":   nil,		"interfaces":    []interface{}{},		"enumValues":    nil,		"possibleTypes": nil,	}	res = append(res, subscriptionType)	// Add EliasDB specific types	res = append(res, rt.GetEliasDBTypesIntrospection().([]interface{})...)	// Add all the default GraphQL types like __Schema, __Type, etc.	res = append(res, rt.GetStandardTypesIntrospection().([]interface{})...)	return res}/*GetFieldTypesIntrospection returns the introspection for all available field types.*/func (rt *selectionSetRuntime) GetFieldTypesIntrospection(action string, lookupArgs bool) interface{} {	var args []interface{}	res := make([]interface{}, 0)	if lookupArgs {		args = []interface{}{			map[string]interface{}{				"name":         "key",				"defaultValue": nil,				"description":  "Lookup a particular node by key.",				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "String",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "matches",				"defaultValue": nil,				"description":  "Lookup nodes matching this template.",				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "NodeTemplate",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "storeNode",				"defaultValue": nil,				"description":  "Store a node according to this template.",				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "NodeTemplate",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "removeNode",				"defaultValue": nil,				"description":  "Remove a node according to this template.",				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "NodeTemplate",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "storeEdge",				"defaultValue": nil,				"description":  "Store an edge according to this template (only key and kind are needed).",				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "NodeTemplate",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "removeEdge",				"defaultValue": nil,				"description":  "Remove an edge according to this template (only key and kind are needed).",				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "NodeTemplate",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "ascending",				"defaultValue": nil,				"description":  "Sort resuting data ascending using the values of the specified key.",				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "String",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "descending",				"defaultValue": nil,				"description":  "Sort resuting data descending using the values of the specified key.",				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "String",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "from",				"defaultValue": nil,				"description":  "Retrieve data after the first n entries.",				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "Int",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "items",				"defaultValue": nil,				"description":  "Retrieve n entries.",				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "Int",					"ofType": nil,				},			},			map[string]interface{}{				"name":         "last",				"defaultValue": nil,				"description":  "Only return last n entries.",				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "Int",					"ofType": nil,				},			},		}	} else {		args = []interface{}{}	}	for _, kind := range rt.rtp.gm.NodeKinds() {		res = append(res, map[string]interface{}{			"name":        kind,			"description": fmt.Sprintf("%s %s nodes in the datastore.", action, kind),			"args":        args,			"type": map[string]interface{}{				"kind": "LIST",				"name": nil,				"ofType": map[string]interface{}{					"kind":   "OBJECT",					"name":   fmt.Sprintf("%sNode", strings.Title(kind)),					"ofType": nil,				},			},			"isDeprecated":      false,			"deprecationReason": nil,		})	}	return res}/*GetEliasDBTypesIntrospection returns EliasDB types.*/func (rt *selectionSetRuntime) GetEliasDBTypesIntrospection() interface{} {	res := make([]interface{}, 0)	for _, kind := range rt.rtp.gm.NodeKinds() {		fields := make([]interface{}, 0)		for _, attr := range rt.rtp.gm.NodeAttrs(kind) {			fields = append(fields, map[string]interface{}{				"name":        attr,				"description": fmt.Sprintf("The %s attribute of a %s node.", attr, kind),				"args":        []interface{}{},				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "String",					"ofType": nil,				},				"isDeprecated":      false,				"deprecationReason": nil,			})		}		for _, edge := range rt.rtp.gm.NodeEdges(kind) {			edgeName := strings.Replace(edge, ":", "_", -1)			edgeTargetKind := strings.Split(edge, ":")[3]			fields = append(fields, map[string]interface{}{				"name":        edgeName,				"description": fmt.Sprintf("The %s edge of a %s node to a %s node.", edge, kind, edgeTargetKind),				"args": []interface{}{					map[string]interface{}{						"name":         "traverse",						"defaultValue": nil,						"description":  fmt.Sprintf("Use %s to traverse from %s to %s.", edge, kind, edgeTargetKind),						"type": map[string]interface{}{							"kind": "NON_NULL",							"name": nil,							"ofType": map[string]interface{}{								"kind":   "SCALAR",								"name":   "String",								"ofType": nil,							},						},					},					map[string]interface{}{						"name":         "matches",						"defaultValue": nil,						"description":  "Lookup nodes matching this template.",						"type": map[string]interface{}{							"kind":   "OBJECT",							"name":   "NodeTemplate",							"ofType": nil,						},					},					map[string]interface{}{						"name":         "ascending",						"defaultValue": nil,						"description":  "Sort resuting data ascending using the values of the specified key.",						"type": map[string]interface{}{							"kind":   "SCALAR",							"name":   "String",							"ofType": nil,						},					},					map[string]interface{}{						"name":         "descending",						"defaultValue": nil,						"description":  "Sort resuting data descending using the values of the specified key.",						"type": map[string]interface{}{							"kind":   "SCALAR",							"name":   "String",							"ofType": nil,						},					},					map[string]interface{}{						"name":         "from",						"defaultValue": nil,						"description":  "Retrieve data after the first n entries.",						"type": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Int",							"ofType": nil,						},					},					map[string]interface{}{						"name":         "items",						"defaultValue": nil,						"description":  "Retrieve n entries.",						"type": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Int",							"ofType": nil,						},					},					map[string]interface{}{						"name":         "last",						"defaultValue": nil,						"description":  "Only return last n entries.",						"type": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Int",							"ofType": nil,						},					},				},				"type": map[string]interface{}{					"kind": "LIST",					"name": nil,					"ofType": map[string]interface{}{						"kind":   "OBJECT",						"name":   fmt.Sprintf("%sNode", strings.Title(edgeTargetKind)),						"ofType": nil,					},				},				"isDeprecated":      false,				"deprecationReason": nil,			})		}		res = append(res, map[string]interface{}{			"kind":          "OBJECT",			"name":          fmt.Sprintf("%sNode", strings.Title(kind)),			"description":   fmt.Sprintf("Represents a %s node.", kind),			"fields":        fields,			"inputFields":   nil,			"interfaces":    []interface{}{},			"enumValues":    nil,			"possibleTypes": nil,		})	}	res = append(res, map[string]interface{}{		"kind":          "INPUT_OBJECT",		"name":          "NodeTemplate",		"description":   "Template of a node. Fields of this object can either be regular expressions or direct matches. A `not_` prefix negates the condition (e.g. `not_key`).",		"fields":        []interface{}{},		"inputFields":   []interface{}{},		"interfaces":    []interface{}{},		"enumValues":    nil,		"possibleTypes": nil,	})	return res}/*GetStandardTypesIntrospection returns the standard types.*/func (rt *selectionSetRuntime) GetStandardTypesIntrospection() interface{} {	res := make([]interface{}, 0)	// Schema type	res = append(res, map[string]interface{}{		"kind":        "OBJECT",		"name":        "__Schema",		"description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",		"fields": []interface{}{			map[string]interface{}{				"name":        "types",				"description": "A list of all types supported by this server.",				"args":        []interface{}{},				"type": map[string]interface{}{					"kind": "NON_NULL",					"name": nil,					"ofType": map[string]interface{}{						"kind": "LIST",						"name": nil,						"ofType": map[string]interface{}{							"kind": "NON_NULL",							"name": nil,							"ofType": map[string]interface{}{								"kind":   "OBJECT",								"name":   "__Type",								"ofType": nil,							},						},					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "queryType",				"description": "The type that query operations will be rooted at.",				"args":        []interface{}{},				"type": map[string]interface{}{					"kind": "NON_NULL",					"name": nil,					"ofType": map[string]interface{}{						"kind":   "OBJECT",						"name":   "__Type",						"ofType": nil,					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "mutationType",				"description": "The type that mutation operations will be rooted at.",				"args":        []interface{}{},				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "__Type",					"ofType": nil,				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "subscriptionType",				"description": "The type that subscription operations will be rooted at.",				"args":        []interface{}{},				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "__Type",					"ofType": nil,				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "directives",				"description": "A list of all directives supported by this server.",				"args":        []interface{}{},				"type": map[string]interface{}{					"kind": "NON_NULL",					"name": nil,					"ofType": map[string]interface{}{						"kind": "LIST",						"name": nil,						"ofType": map[string]interface{}{							"kind": "NON_NULL",							"name": nil,							"ofType": map[string]interface{}{								"kind":   "OBJECT",								"name":   "__Directive",								"ofType": nil,							},						},					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},		},		"inputFields":   nil,		"interfaces":    []interface{}{},		"enumValues":    nil,		"possibleTypes": nil,	})	// Type type	res = append(res, map[string]interface{}{		"kind":        "OBJECT",		"name":        "__Type",		"description": "The fundamental unit of the GraphQL Schema.",		"fields": []interface{}{			map[string]interface{}{				"name":        "kind",				"description": nil,				"args":        []interface{}{},				"type": map[string]interface{}{					"kind": "NON_NULL",					"name": nil,					"ofType": map[string]interface{}{						"kind":   "ENUM",						"name":   "__TypeKind",						"ofType": nil,					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "name",				"description": nil,				"args":        []interface{}{},				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "String",					"ofType": nil,				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "description",				"description": nil,				"args":        []interface{}{},				"type": map[string]interface{}{					"kind":   "SCALAR",					"name":   "String",					"ofType": nil,				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "fields",				"description": nil,				"args": []interface{}{					map[string]interface{}{						"name":        "includeDeprecated",						"description": nil,						"type": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Boolean",							"ofType": nil,						},						"defaultValue": "false",					},				},				"type": map[string]interface{}{					"kind": "LIST",					"name": nil,					"ofType": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "OBJECT",							"name":   "__Field",							"ofType": nil,						},					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "interfaces",				"description": nil,				"args":        []interface{}{},				"type": map[string]interface{}{					"kind": "LIST",					"name": nil,					"ofType": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "OBJECT",							"name":   "__Type",							"ofType": nil,						},					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "possibleTypes",				"description": nil,				"args":        []interface{}{},				"type": map[string]interface{}{					"kind": "LIST",					"name": nil,					"ofType": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "OBJECT",							"name":   "__Type",							"ofType": nil,						},					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "enumValues",				"description": nil,				"args": []interface{}{					map[string]interface{}{						"name":        "includeDeprecated",						"description": nil,						"type": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Boolean",							"ofType": nil,						},						"defaultValue": "false",					},				},				"type": map[string]interface{}{					"kind": "LIST",					"name": nil,					"ofType": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "OBJECT",							"name":   "__EnumValue",							"ofType": nil,						},					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "inputFields",				"description": nil,				"args":        []interface{}{},				"type": map[string]interface{}{					"kind": "LIST",					"name": nil,					"ofType": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "OBJECT",							"name":   "__InputValue",							"ofType": nil,						},					},				},				"isDeprecated":      false,				"deprecationReason": nil,			},			map[string]interface{}{				"name":        "ofType",				"description": nil,				"args":        []interface{}{},				"type": map[string]interface{}{					"kind":   "OBJECT",					"name":   "__Type",					"ofType": nil,				},				"isDeprecated":      false,				"deprecationReason": nil,			},		},		"inputFields":   nil,		"interfaces":    []interface{}{},		"enumValues":    nil,		"possibleTypes": nil,	})	// Default types	res = append(res, []interface{}{		map[string]interface{}{			"kind":          "SCALAR",			"name":          "String",			"description":   "The `String` scalar type represents textual data, represented as UTF-8 character sequences.",			"fields":        nil,			"inputFields":   nil,			"interfaces":    nil,			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":          "SCALAR",			"name":          "Boolean",			"description":   "The `Boolean` scalar type represents `true` or `false`.",			"fields":        nil,			"inputFields":   nil,			"interfaces":    nil,			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":          "SCALAR",			"name":          "Float",			"description":   "The `Float` scalar type represents signed double-precision fractional values.",			"fields":        nil,			"inputFields":   nil,			"interfaces":    nil,			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":          "SCALAR",			"name":          "Int",			"description":   "The `Int` scalar type represents non-fractional signed whole numeric values.",			"fields":        nil,			"inputFields":   nil,			"interfaces":    nil,			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":        "OBJECT",			"name":        "__InputValue",			"description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",			"fields": []interface{}{				map[string]interface{}{					"name":        "name",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "String",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "description",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind":   "SCALAR",						"name":   "String",						"ofType": nil,					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "type",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "OBJECT",							"name":   "__Type",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "defaultValue",					"description": "A GraphQL-formatted string representing the default value for this input value.",					"args":        []interface{}{},					"type": map[string]interface{}{						"kind":   "SCALAR",						"name":   "String",						"ofType": nil,					},					"isDeprecated":      false,					"deprecationReason": nil,				},			},			"inputFields":   nil,			"interfaces":    []interface{}{},			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":        "OBJECT",			"name":        "__EnumValue",			"description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. Enum values are returned in a JSON response as strings.",			"fields": []interface{}{				map[string]interface{}{					"name":        "name",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "String",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "description",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind":   "SCALAR",						"name":   "String",						"ofType": nil,					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "isDeprecated",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Boolean",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "deprecationReason",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind":   "SCALAR",						"name":   "String",						"ofType": nil,					},					"isDeprecated":      false,					"deprecationReason": nil,				},			},			"inputFields":   nil,			"interfaces":    []interface{}{},			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":        "ENUM",			"name":        "__TypeKind",			"description": "An enum describing what kind of type a given `__Type` is.",			"fields":      nil,			"inputFields": nil,			"interfaces":  nil,			"enumValues": []interface{}{				map[string]interface{}{					"name":              "SCALAR",					"description":       "Indicates this type is a scalar.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "OBJECT",					"description":       "Indicates this type is an object. `fields` and `interfaces` are valid fields.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "INTERFACE",					"description":       "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "UNION",					"description":       "Indicates this type is a union. `possibleTypes` is a valid field.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "ENUM",					"description":       "Indicates this type is an enum. `enumValues` is a valid field.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "INPUT_OBJECT",					"description":       "Indicates this type is an input object. `inputFields` is a valid field.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "LIST",					"description":       "Indicates this type is a list. `ofType` is a valid field.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "NON_NULL",					"description":       "Indicates this type is a non-null. `ofType` is a valid field.",					"isDeprecated":      false,					"deprecationReason": nil,				},			},			"possibleTypes": nil,		},		map[string]interface{}{			"kind":        "OBJECT",			"name":        "__Field",			"description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",			"fields": []interface{}{				map[string]interface{}{					"name":        "name",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "String",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "description",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind":   "SCALAR",						"name":   "String",						"ofType": nil,					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "args",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind": "LIST",							"name": nil,							"ofType": map[string]interface{}{								"kind": "NON_NULL",								"name": nil,								"ofType": map[string]interface{}{									"kind":   "OBJECT",									"name":   "__InputValue",									"ofType": nil,								},							},						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "type",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "OBJECT",							"name":   "__Type",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "isDeprecated",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Boolean",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "deprecationReason",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind":   "SCALAR",						"name":   "String",						"ofType": nil,					},					"isDeprecated":      false,					"deprecationReason": nil,				},			},			"inputFields":   nil,			"interfaces":    []interface{}{},			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":        "OBJECT",			"name":        "__Directive",			"description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.",			"fields": []interface{}{				map[string]interface{}{					"name":        "name",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "String",							"ofType": nil,						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "description",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind":   "SCALAR",						"name":   "String",						"ofType": nil,					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "locations",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind": "LIST",							"name": nil,							"ofType": map[string]interface{}{								"kind": "NON_NULL",								"name": nil,								"ofType": map[string]interface{}{									"kind":   "ENUM",									"name":   "__DirectiveLocation",									"ofType": nil,								},							},						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":        "args",					"description": nil,					"args":        []interface{}{},					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind": "LIST",							"name": nil,							"ofType": map[string]interface{}{								"kind": "NON_NULL",								"name": nil,								"ofType": map[string]interface{}{									"kind":   "OBJECT",									"name":   "__InputValue",									"ofType": nil,								},							},						},					},					"isDeprecated":      false,					"deprecationReason": nil,				},			},			"inputFields":   nil,			"interfaces":    []interface{}{},			"enumValues":    nil,			"possibleTypes": nil,		},		map[string]interface{}{			"kind":        "ENUM",			"name":        "__DirectiveLocation",			"description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",			"fields":      nil,			"inputFields": nil,			"interfaces":  nil,			"enumValues": []interface{}{				map[string]interface{}{					"name":              "QUERY",					"description":       "Location adjacent to a query operation.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "MUTATION",					"description":       "Location adjacent to a mutation operation.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "SUBSCRIPTION",					"description":       "Location adjacent to a subscription operation.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "FIELD",					"description":       "Location adjacent to a field.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "FRAGMENT_DEFINITION",					"description":       "Location adjacent to a fragment definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "FRAGMENT_SPREAD",					"description":       "Location adjacent to a fragment spread.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "INLINE_FRAGMENT",					"description":       "Location adjacent to an inline fragment.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "SCHEMA",					"description":       "Location adjacent to a schema definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "SCALAR",					"description":       "Location adjacent to a scalar definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "OBJECT",					"description":       "Location adjacent to an object type definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "FIELD_DEFINITION",					"description":       "Location adjacent to a field definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "ARGUMENT_DEFINITION",					"description":       "Location adjacent to an argument definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "INTERFACE",					"description":       "Location adjacent to an interface definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "UNION",					"description":       "Location adjacent to a union definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "ENUM",					"description":       "Location adjacent to an enum definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "ENUM_VALUE",					"description":       "Location adjacent to an enum value definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "INPUT_OBJECT",					"description":       "Location adjacent to an input object type definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},				map[string]interface{}{					"name":              "INPUT_FIELD_DEFINITION",					"description":       "Location adjacent to an input object field definition.",					"isDeprecated":      false,					"deprecationReason": nil,				},			},			"possibleTypes": nil,		},	}...)	return res}/*GetDirectivesIntrospection returns the introspection for all available directives.*/func (rt *selectionSetRuntime) GetDirectivesIntrospection() interface{} {	return []interface{}{		map[string]interface{}{			"name":        "skip",			"description": "Directs the executor to skip this field or fragment when the `if` argument is true.",			"locations": []interface{}{				"FIELD",				"FRAGMENT_SPREAD",				"INLINE_FRAGMENT",			},			"args": []interface{}{				map[string]interface{}{					"name":        "if",					"description": "Skipped when true.",					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Boolean",							"ofType": nil,						},					},					"defaultValue": nil,				},			},		},		map[string]interface{}{			"name":        "include",			"description": "Directs the executor to include this field or fragment only when the `if` argument is true.",			"locations": []interface{}{				"FIELD",				"FRAGMENT_SPREAD",				"INLINE_FRAGMENT",			},			"args": []interface{}{				map[string]interface{}{					"name":        "if",					"description": "Included when true.",					"type": map[string]interface{}{						"kind": "NON_NULL",						"name": nil,						"ofType": map[string]interface{}{							"kind":   "SCALAR",							"name":   "Boolean",							"ofType": nil,						},					},					"defaultValue": nil,				},			},		},	}}/*GetFields returns all fields of this selection set.*/func (rt *selectionSetRuntime) GetFields() map[string]*fieldRuntime {	resMap := make(map[string]*fieldRuntime)	fieldList := append(rt.node.Children[:0:0], rt.node.Children...) // Copy into new slice	for i := 0; i < len(fieldList); i++ {		c := fieldList[i]		// Check for skip and include directive		if rt.skipField([]string{}, c) {			continue		}		if c.Name == parser.NodeField {			// Handle simple fields - we ignore aliases as they will not be honored			// when filtering the introspection data			field := c.Runtime.(*fieldRuntime)			resMap[field.Name()] = field		} else if c.Name == parser.NodeFragmentSpread || c.Name == parser.NodeInlineFragment {			var fd fragmentRuntime			if c.Name == parser.NodeFragmentSpread {				// Lookup fragment spreads				fd = rt.rtp.fragments[c.Token.Val]			} else {				// Construct inline fragments				fd = c.Runtime.(*inlineFragmentDefinitionRuntime)			}			ss := fd.SelectionSet()			fieldList = append(fieldList, ss.Children...)		}	}	return resMap}
 |