A GraphQL server: schemas, resolvers, query execution and HTTP handling.
Types
The internal state of execution.
Name Type Description schSchemaThe schema. docDocumentThe document. varsvalue.ValueThe variables. ctxvalue.ValueThe context. errorsGqlErrorListThe errors. pathKeysVector<str>The current path. pathIdxVector<int>The indexes of the path. depthint = 0The depth. maxDepthint = 512The greatest depth allowed.
graphql-Execute.salam Copy
import graphql
import encoding.value
func book (id: str , title: str , year: i64 ): value.Value:
mut b := value. NewValueObject ()
value. ObjectSet (b, "id" , value. ValueString (id))
value. ObjectSet (b, "title" , value. ValueString (title))
value. ObjectSet (b, "year" , value. ValueInt (year))
ret b
end
func hello (slot: i64 ):
graphql. ResolveStr (slot, "Hello " + graphql. ArgStr (slot, "name" ))
end
func books (slot: i64 ):
mut list := value. NewValueArray ()
value. ArrayPush (list, book ( "1" , "The Blind Owl" , 1936 ))
value. ArrayPush (list, book ( "2" , "Savushun" , 1969 ))
graphql. Resolve (slot, list)
end
func one_book (slot: i64 ):
if graphql. ArgInt (slot, "id" ) == 2 and not value. IsNull (graphql. Arg (slot, "id" )):
graphql. Resolve (slot, book ( "2" , "Savushun" , 1969 ))
else :
graphql. ResolveNull (slot)
end
end
func age (slot: i64 ):
if not value. IsObject (graphql. Parent (slot)):
graphql. ResolveNull (slot)
ret
end
year := value. AsInt (graphql. ParentField (slot, "year" ))
graphql. ResolveInt (slot, 2026 - year)
end
func score (slot: i64 ):
graphql. ResolveFloat (slot, graphql. ArgFloat (slot, "base" ) * 2.0 )
end
func in_stock (slot: i64 ):
graphql. ResolveBool (slot, graphql. ArgBool (slot, "only" ) or graphql. HasArg (slot, "x" ))
end
func broken (slot: i64 ):
graphql. Fail (slot, "service unavailable" )
end
func main :
mut err := graphql. NewError (graphql.ERR_SYNTAX, "" )
mut s := graphql. ParseSchema ( `
type Query {
hello(name: String = "world"): String!
books: [Book!]!
book(id: Int!): Book
score(base: Float!): Float!
inStock(only: Boolean!): Boolean!
broken: String
}
type Book {
id: ID!
title: String!
year: Int!
age: Int!
}` , err)
_ := graphql. SetResolver (s, "Query" , "hello" , hello)
_ := graphql. SetResolver (s, "Query" , "books" , books)
_ := graphql. SetResolver (s, "Query" , "book" , one_book)
_ := graphql. SetResolver (s, "Query" , "score" , score)
_ := graphql. SetResolver (s, "Query" , "inStock" , in_stock)
_ := graphql. SetResolver (s, "Query" , "broken" , broken)
_ := graphql. SetResolver (s, "Book" , "age" , age)
println graphql. HasResolver (s, "Book" , "age" ), graphql. HasResolver (s, "Book" , "title" )
mut r := graphql. Run (s, `{ hello books { title year age } }` )
println graphql. ResultOk (r)
println graphql. ResultToJSONStable (r)
graphql. FreeResult (r)
mut vars := value. NewValueObject ()
value. ObjectSet (vars, "id" , value. ValueInt ( 2 ))
mut r2 := graphql. ExecuteSource (
s,
`query One($id: Int!) { book(id: $id) { title } missing: book(id: 9) { title } score(base: 1.5) inStock(only: true) hello(name: "Maryam") }` ,
"One" ,
vars,
value. ValueNull (),
value. ValueNull ()
)
println graphql. ResultToJSONStable (r2)
graphql. FreeResult (r2)
mut r3 := graphql. Run (s, `{ broken hello }` )
println graphql. ResultOk (r3), graphql. ResultErrorMessage (r3)
println graphql. ResultToJSONStable (r3)
graphql. FreeResult (r3)
mut r4 := graphql. Run (s, `{ nope }` )
println graphql. ResultErrorMessage (r4)
graphql. FreeResult (r4)
graphql. ResetSlots ()
graphql. FreeSchema (s)
end Output true false
true
{"data": {"books": [{"age": 90, "title": "The Blind Owl", "year": 1936}, {"age": 57, "title": "Savushun", "year": 1969}], "hello": "Hello world"}}
{"data": {"book": {"title": "Savushun"}, "hello": "Hello Maryam", "inStock": true, "missing": null, "score": 3}}
false service unavailable (line 1, column 3) at broken
{"data": {"broken": null, "hello": "Hello world"}, "errors": [{"locations": [{"column": 3, "line": 1}], "message": "service unavailable", "path": ["broken"]}]}
cannot query field "nope" on type "Query" (line 1, column 3)
Name Type Description categoryintThe category. messagestr = ""The message. lineint = 0The line. colint = 0The column. hasLocationbool = falseIt has a location. pathKeysVector<str>The keys of the path in the response. pathIndexVector<int>The indexes of the path; -1 for a key. codestr = ""An optional code in extensions.
graphql-Document.salam Copy
import graphql
import encoding.value
func main :
source := `query Books($limit: Int = 5) { books(limit: $limit, tags: ["a", "b"]) @include(if: true) { ...Info alias: title } }
fragment Info on Book { id year }`
println graphql. ParseOk (source), graphql. ParseOk ( "{ a " ), graphql. LexOk ( "{ a }" )
mut err := graphql. NewError (graphql.ERR_SYNTAX, "" )
mut doc := graphql. Parse (source, err)
println doc.ops. Len (), doc.frags. Len ()
print graphql. Print (doc)
i := graphql. FindOperation (doc, "Books" )
op := doc.ops. Get (i)
println op.name, graphql. OperationTypeName (op.optype), op.shorthand, op.varDefs. Len (), op.line
sel := graphql. SelectionAt (doc, op.selections. Get ( 0 ))
println sel.kind == graphql.SEL_FIELD,
sel.name,
graphql. ResponseKey (sel),
sel.args. Len (),
sel.directives. Len (),
sel.selections. Len (),
sel.line,
sel.col
arg := sel.args. Get ( 1 )
println arg.name,
graphql. PrintValue (doc, arg.value),
graphql. ValueAt (doc, arg.value).kind == graphql.VAL_LIST
vdef := op.varDefs. Get ( 0 )
println vdef.name,
graphql. PrintTypeRef (doc, vdef.typeRef),
graphql. TypeRefName (doc, vdef.typeRef)
println graphql. TypeRefIsNonNull (doc, vdef.typeRef),
graphql. TypeRefIsList (doc, vdef.typeRef),
graphql. TypeRefAt (doc, vdef.typeRef).name
frag := doc.frags. Get (graphql. FindFragment (doc, "Info" ))
println frag.name, frag.typeCondition, frag.selections. Len ()
println graphql. PrintStringValue ( "hello \"world\"" )
graphql. FreeDocument (doc)
mut ok := false
stream := graphql. Tokenize ( `{ a(x: 1.5, y: "s") }` , ok)
println ok, stream.toks. Len ()
tok := stream.toks. Get ( 5 )
println graphql. TokenKindName (tok.kind), tok.lexeme, tok.fval, tok.line, tok.col
println graphql. IsStringToken (graphql.TOK_STRING), graphql. TokenKindName (graphql.TOK_LBRACE)
_ := graphql. Parse ( "{ a(" , err)
println err.category == graphql.ERR_SYNTAX, err.line, err.col, err.hasLocation
println graphql. ErrorString (err)
mut e := graphql. NewError (graphql.ERR_EXECUTION, "failed" )
graphql. PathPushKey (e, "books" )
graphql. PathPushIndex (e, 2 )
graphql. PathPushKey (e, "title" )
println graphql. PathLen (e), graphql. PathString (e)
mut errs := graphql.GqlErrorList {}
graphql. AddError (errs, e)
graphql. AddError (errs, graphql. NewErrorAt (graphql.ERR_VALIDATION, "bad" , 3 , 7 ))
graphql. AddError (errs, graphql. SyntaxError ( "unclosed parenthesis" , 1 , 4 ))
println graphql. HasErrors (errs), graphql. ErrorCount (errs), graphql. ErrorAt (errs, 1 ).line
println value. ArrayLen (graphql. ErrorsToValue (errs)), value. IsObject (graphql. ErrorToValue (e))
graphql. FreeError (err)
graphql. FreeErrorList (errs)
println graphql.ERR_REQUEST, graphql.SpecEdition
mut s := graphql. ParseSchema ( "type Query { n(x: Int!): Int e: Color } enum Color { RED }" , err)
println graphql. ValidateSource (s, "{ n(x: \"a\") }" ).items. Len () > 0
mut doc2 := graphql. Parse ( "{ n(x: 1) e }" , err)
println graphql. ValidateOk (s, doc2), graphql. Validate (s, doc2).items. Len ()
c := graphql. CoerceLeafResult (s, "Color" , value. ValueString ( "RED" ))
println c.ok, value. AsString (c.value)
c2 := graphql. CoerceLeafResult (s, "Int" , value. ValueString ( "x" ))
println c2.ok, c2.message. Len () > 0
graphql. FreeDocument (doc2)
graphql. FreeSchema (s)
end Output true false true
1 1
query Books($limit: Int = 5) {
books(limit: $limit, tags: ["a", "b"]) @include(if: true) {
...Info
alias: title
}
}
fragment Info on Book {
id
year
}
Books query false 1 1
true books books 2 1 2 1 32
tags ["a", "b"] true
limit Int Int
false false Int
Info Book 2
"hello \"world\""
true 12
Float 1.5 1.5 1 8
true {
true 1 5 true
unterminated argument list (line 1, column 5)
3 books[2].title
true 3 3
3 true
3 October2021
true
true 0
true RED
false true
Name Type Description itemsVector<GqlError>The errors.
The example for this item is shown with the ones above: graphql-Document.salam
Name Type Description kindintThe kind, one of the TOK_... constants. lexemestr = ""The text. svalstr = ""The string value. ivali64 = 0The integer value. fvalf64 = 0The float value. lineint = 0The line. colint = 0The column. posint = 0Where it starts in the text.
The example for this item is shown with the ones above: graphql-Document.salam
Name Type Description toksVector<GqlToken>The tokens.
The example for this item is shown with the ones above: graphql-Document.salam
The result of an execution.
Name Type Description datavalue.ValueThe data. hasDatabool = falseIt has data; not when the request never ran at all. errorsGqlErrorListThe errors. extensionsvalue.ValueThe extensions. hasExtensionsbool = falseIt has extensions.
The example for this item is shown with the ones above: graphql-Execute.salam
The internal state of validation.
Name Type Description schSchemaThe schema. docDocumentThe document. errorsGqlErrorListThe errors. usedFragmentsVector<str>The fragments that were used. usedVarsVector<str>The variables that were used.
The example for this item is shown with the ones above: graphql-Document.salam
The group of selections for one response key.
Name Type Description keystr = ""The key. selsVector<int>The selections.
The example for this item is shown with the ones above: graphql-Execute.salam
Name Type Description itemsVector<FieldGroup>The groups.
graphql-Internals.salam Copy
import graphql
import encoding.value
import encoding.json
func names (slot: i64 ):
graphql. ResolveStr (slot, json. EncodeDefault (graphql. Args (slot)))
end
func main :
mut ok := false
stream := graphql. Tokenize (
`query Q($v: [Int!]! = [1]) @x { ...F a: b(c: 2.5, d: """text""") | & ? }` , ok
)
mut kinds := ""
each t in stream.toks:
if kinds. Len () > 0 :
kinds += " "
end
kinds += graphql. TokenKindName (t.kind)
end
println ok, kinds
println graphql.TOK_EOF,
graphql.TOK_NAME,
graphql.TOK_INT,
graphql.TOK_FLOAT,
graphql.TOK_BLOCK_STRING,
graphql.TOK_BANG,
graphql.TOK_DOLLAR
println graphql.TOK_AMP,
graphql.TOK_LPAREN,
graphql.TOK_RPAREN,
graphql.TOK_SPREAD,
graphql.TOK_COLON,
graphql.TOK_EQUALS,
graphql.TOK_AT
println graphql.TOK_LBRACKET,
graphql.TOK_RBRACKET,
graphql.TOK_RBRACE,
graphql.TOK_PIPE,
graphql.TOK_ERROR
mut err := graphql. NewError (graphql.ERR_SYNTAX, "" )
mut s := graphql. ParseSchema ( `
type Query { names(a: Boolean, b: Float, o: In, v: Int): String! book: Book }
input In { x: Int! }
type Book { id: ID! title: String! }` , err)
_ := graphql. SetResolver (s, "Query" , "names" , names)
mut doc := graphql. Parse ( `query ($v: Int, $l: [Int!]) { names(a: true, b: 1.5, o: { x: 3 }, v: $v) book { id ...F ... on Book { title } } }
fragment F on Book { title }` , err)
op := doc.ops. Get ( 0 )
println op.optype == graphql.OP_QUERY
sel := graphql. SelectionAt (doc, op.selections. Get ( 0 ))
mut vars := value. NewValueObject ()
value. ObjectSet (vars, "v" , value. ValueInt ( 42 ))
each a in sel.args:
v := graphql. ValueAt (doc, a.value)
lit := graphql. LiteralToValue (s, doc, a.value, vars)
println a.name,
v.kind == graphql.VAL_BOOL,
v.kind == graphql.VAL_FLOAT,
v.kind == graphql.VAL_OBJECT,
v.kind == graphql.VAL_VARIABLE,
lit.ok,
json. EncodeDefault (lit.value)
end
lref := op.varDefs. Get ( 1 ).typeRef
elem := graphql. TypeRefElement (doc, lref)
println graphql. PrintTypeRef (doc, lref),
graphql. PrintTypeRef (doc, elem),
graphql. TypeRefAt (doc, elem).kind == graphql.TREF_NAMED
mut list := value. NewValueArray ()
value. ArrayPush (list, value. ValueInt ( 1 ))
value. ArrayPush (list, value. ValueString ( "two" ))
c := graphql. CoerceInput (s, doc, lref, list)
println c.ok, c.message. Len () > 0
bk := graphql. SelectionAt (doc, op.selections. Get ( 1 ))
println graphql. SelectionAt (doc, bk.selections. Get ( 1 )).kind == graphql.SEL_FRAGMENT_SPREAD,
graphql. SelectionAt (doc, bk.selections. Get ( 2 )).kind == graphql.SEL_INLINE_FRAGMENT
mut groups := graphql. CollectFields (s, doc, bk.selections, "Book" , vars)
each g in groups.items:
println g.key, g.sels. Len (), graphql. MergeSelections (doc, g). Len ()
end
graphql. FreeFieldGroups (groups)
mut r := graphql. Execute (s, doc, "" , vars, value. ValueNull (), value. ValueNull ())
mut ext := value. NewValueObject ()
value. ObjectSet (ext, "ms" , value. ValueInt ( 3 ))
graphql. SetExtensions (r, ext)
println value. IsObject (graphql. ResultToValue (r))
println graphql. ResultToJSONIndent (r)
graphql. FreeResult (r)
graphql. FreeDocument (doc)
graphql. FreeSchema (s)
graphql. FreeError (err)
end Output false Name Name ( $ Name : [ Name ! ] ! = [ Int ] ) @ Name { ... Name Name : Name ( Name : Float Name : BlockString ) | & <error> } <EOF>
0 1 2 3 5 6 7
8 9 10 11 12 13 14
15 16 18 19 20
true
a true false false false true true
b false true false false true 1.5
o false false true false true {"x": 3}
v false false false true true 42
[Int!] Int! true
false true
true true
id 1 0
title 2 0
true
{
"data": {
"names": "{\"a\": true, \"b\": 1.5, \"o\": {\"x\": 3}, \"v\": 42}",
"book": null
},
"extensions": {
"ms": 3
}
}
Name Type Description kindintThe kind, one of the VAL_... constants. bbool = falseThe boolean value. ii64 = 0The integer value. ff64 = 0The float value. sstr = ""The string, the enum name or the variable name. itemsVector<int>The list elements or the object values. keysVector<str>The object keys. lineint = 0The line.
The example for this item is shown with the ones above: graphql-Document.salam
Name Type Description kindintNamed or list. namestr = ""The type name. innerint = -1The inner reference of a list. nonNullbool = falseNon null, with a !.
graphql-Schema.salam Copy
import graphql
func main :
mut s := graphql. NewSchema ()
graphql. AddScalarType (s, "Date" , "A date as YYYY-MM-DD" )
graphql. AddInterfaceType (s, "Node" , "" )
_ := graphql. AddField (s, "Node" , "id" , "ID!" )
graphql. AddObjectType (s, "Author" , "An author" )
graphql. AddInterfaceTo (s, "Author" , "Node" )
_ := graphql. AddField (s, "Author" , "id" , "ID!" )
_ := graphql. AddField (s, "Author" , "name" , "String!" )
_ := graphql. AddField (s, "Author" , "born" , "Date" )
mut genres := Vector {} as Vector < str >
genres. Push ( "NOVEL" )
genres. Push ( "POETRY" )
graphql. AddEnumType (s, "Genre" , genres)
mut members := Vector {} as Vector < str >
members. Push ( "Author" )
graphql. AddUnionType (s, "SearchResult" , members)
graphql. AddInputObjectType (s, "AuthorInput" , "" )
_ := graphql. AddInputField (s, "AuthorInput" , "name" , "String!" )
graphql. AddObjectType (s, "Query" , "" )
_ := graphql. AddField (s, "Query" , "authors" , "[Author!]!" )
_ := graphql. AddField (s, "Query" , "search" , "[SearchResult!]!" )
_ := graphql. AddFieldArg (s, "Query" , "search" , "text" , "String!" )
_ := graphql. AddFieldArg (s, "Query" , "search" , "genre" , "Genre" )
graphql. AddObjectType (s, "Mutation" , "" )
_ := graphql. AddField (s, "Mutation" , "addAuthor" , "Author!" )
_ := graphql. AddFieldArg (s, "Mutation" , "addAuthor" , "input" , "AuthorInput!" )
graphql. SetRootTypes (s, "Query" , "Mutation" , "" )
print graphql. PrintSchema (s)
println "---"
println graphql. PrintType (s, "Genre" )
println graphql. HasType (s, "Author" ),
graphql. TypeIndex (s, "Author" ) >= 0 ,
graphql. TypeCount (s) > 5
t := graphql. FindType (s, "Author" )
println t.name, t.kind == graphql.TYPE_OBJECT, t.description, graphql. HasField (t, "born" )
f := graphql. FindField (graphql. FindType (s, "Query" ), "search" )
println f.name, graphql. FindArg (f, "genre" ).name, graphql. FindArg (f, "genre" ).hasDefault
println graphql. FindInputField (graphql. FindType (s, "AuthorInput" ), "name" ).name
println graphql. HasEnumValue (graphql. FindType (s, "Genre" ), "POETRY" )
println graphql. IsInputType (s, "AuthorInput" ),
graphql. IsOutputType (s, "AuthorInput" ),
graphql. IsLeafType (s, "Genre" )
println graphql. IsAbstractType (s, "SearchResult" ),
graphql. IsPossibleType (s, "Node" , "Author" ),
graphql. PossibleTypes (s, "Node" ). Len ()
println graphql. RootTypeName (s, graphql.OP_MUTATION),
graphql. RootTypeName (s, graphql.OP_SUBSCRIPTION). Len ()
println graphql. FindDirectiveDef (s, "deprecated" ).name
println graphql. TypeAt (s, 0 ).name. Len () > 0
println graphql. IsIntrospectionType ( "__Schema" ), graphql. IsIntrospectionType ( "Author" )
graphql. AddIntrospectionTypes (s)
println graphql. HasType (s, "__Type" ),
graphql. PrintSchemaFull (s). Len () > graphql. PrintSchema (s). Len ()
println graphql. TypeRefText (s, "[Int!]" ) >= 0
println graphql. ParseSchemaOk ( "type Query { a: Int }" ), graphql. ParseSchemaOk ( "type {" )
mut err := graphql. NewError (graphql.ERR_SYNTAX, "" )
graphql. ParseSchemaInto (s, "extend type Author { alias: String }" , err)
println graphql. HasField (graphql. FindType (s, "Author" ), "alias" ), err.message. Len ()
println graphql.TYPE_SCALAR,
graphql.TYPE_INTERFACE,
graphql.TYPE_UNION,
graphql.TYPE_ENUM,
graphql.TYPE_INPUT_OBJECT
graphql. FreeSchema (s)
end Output "A date as YYYY-MM-DD"
scalar Date
interface Node {
id: ID!
}
"An author"
type Author implements Node {
id: ID!
name: String!
born: Date
}
enum Genre {
NOVEL
POETRY
}
union SearchResult = Author
input AuthorInput {
name: String!
}
type Query {
authors: [Author!]!
search(text: String!, genre: Genre): [SearchResult!]!
}
type Mutation {
addAuthor(input: AuthorInput!): Author!
}
---
enum Genre {
NOVEL
POETRY
}
true true true
Author true An author true
search genre false
name
true
true false true
true true 1
Mutation 0
deprecated
true
true false
true true
true
true false
true 0
0 2 3 4 5
Name Type Description namestr = ""The name. valueint = -1The number of the value. lineint = 0The line.
The example for this item is shown with the ones above: graphql-Document.salam
One directive, such as @include.
Name Type Description namestr = ""The name. argsVector<AstArgument>The arguments. lineint = 0The line.
The example for this item is shown with the ones above: graphql-Document.salam
One selection: a field, a fragment spread or an inline fragment.
Name Type Description kindintThe kind, one of the SEL_... constants. namestr = ""The name of the field or fragment. aliasstr = ""Another name for the field in the response. typeConditionstr = ""The type of an inline fragment. hasTypeConditionbool = falseIt has a type. argsVector<AstArgument>The arguments. directivesVector<AstDirective>The directives. selectionsVector<int>The sub selections. lineint = 0The line. colint = 0The column.
The example for this item is shown with the ones above: graphql-Document.salam
The definition of a variable.
Name Type Description namestr = ""The name without the $. typeRefint = -1The type reference. defaultValueint = -1The number of the default value. hasDefaultbool = falseIt has a default. directivesVector<AstDirective>The directives. lineint = 0The line.
The example for this item is shown with the ones above: graphql-Document.salam
Name Type Description optypeintThe type, one of the OP_... constants. namestr = ""The name; empty for a shorthand query. varDefsVector<AstVariableDef>The variable definitions. directivesVector<AstDirective>The directives. selectionsVector<int>The numbers of the root selections. shorthandbool = falseIt was written in the short { ... } form. lineint = 0The line.
The example for this item is shown with the ones above: graphql-Document.salam
Name Type Description namestr = ""The name. typeConditionstr = ""The type the fragment applies to. directivesVector<AstDirective>The directives. selectionsVector<int>The selections. lineint = 0The line.
The example for this item is shown with the ones above: graphql-Document.salam
A parsed document: operations and fragments; selections, values and type references are kept by number in the lists of the document.
Name Type Description opsVector<AstOperation>The operations. fragsVector<AstFragment>The fragments. selsVector<AstSelection>The selections. valsVector<AstValue>The values. trefsVector<AstTypeRef>The type references.
The example for this item is shown with the ones above: graphql-Document.salam
The definition of an argument or input field.
Name Type Description namestr = ""The name. descriptionstr = ""The description. typeRefint = -1The type reference. defaultValueint = -1The default value in the document. hasDefaultbool = falseIt has a default value. is_deprecatedbool = falseIt is deprecated. deprecationReasonstr = ""Why it was deprecated.
The example for this item is shown with the ones above: graphql-Schema.salam
The definition of one field.
Name Type Description namestr = ""The name. descriptionstr = ""The description. typeRefint = -1The type reference. argsVector<InputValueDef>The arguments. is_deprecatedbool = falseIt is deprecated. deprecationReasonstr = ""Why it was deprecated. resolveri64 = 0The registered resolver.
The example for this item is shown with the ones above: graphql-Schema.salam
Name Type Description namestr = ""The name. descriptionstr = ""The description. is_deprecatedbool = falseIt is deprecated. deprecationReasonstr = ""Why it was deprecated.
The example for this item is shown with the ones above: graphql-Schema.salam
The definition of one type.
Name Type Description kindintThe kind, one of the TYPE_... constants. namestr = ""The name. descriptionstr = ""The description. fieldsVector<FieldDef>The fields, for objects and interfaces. inputFieldsVector<InputValueDef>The fields of an input type. interfacesVector<str>The interfaces it implements. unionMembersVector<str>The members of a union. enumValuesVector<EnumValueDef>The enum values. specifiedByURLstr = ""The specification URL of a scalar type.
The example for this item is shown with the ones above: graphql-Schema.salam
The definition of a directive.
Name Type Description namestr = ""The name. descriptionstr = ""The description. argsVector<InputValueDef>The arguments. locationsVector<str>Where it can be used. repeatablebool = falseIt may appear more than once in the same place.
The example for this item is shown with the ones above: graphql-Schema.salam
A schema: every type, directive and root type.
Name Type Description docDocumentThe internal document that holds the type references. typesVector<TypeDef>The types. directivesVector<DirectiveDef>The directives. queryTypestr = "Query"The name of the query root type. mutationTypestr = ""The name of the mutation root type. subscriptionTypestr = ""The name of the subscription root type. descriptionstr = ""The schema description. hasSchemaDefbool = falseIt had an explicit schema { ... } block.
The example for this item is shown with the ones above: graphql-Schema.salam
The result of converting one value.
Name Type Description okbool = trueThe conversion worked. messagestr = ""The error message. valuevalue.ValueThe value.
The example for this item is shown with the ones above: graphql-Document.salam
A response the client got from the server.
Name Type Description datavalue.ValueThe data. hasDatabool = falseIt has data. errorsGqlErrorListThe errors. extensionsvalue.ValueThe extensions. hasExtensionsbool = falseIt has extensions.
graphql-Http.salam Copy
import graphql
import encoding.value
import net.http
import net.router
mut schema := graphql. NewSchema ()
func me (slot: i64 ):
ctx := graphql. Context (slot)
mut name := "guest"
if value. ObjectHas (ctx, "user" ):
name = value. AsString (value. ObjectGet (ctx, "user" ))
end
graphql. ResolveStr (
slot, name + " (" + graphql. ParentTypeName (slot) + "." + graphql. FieldName (slot) + ")"
)
end
func add (slot: i64 ):
graphql. ResolveInt (slot, graphql. ArgInt (slot, "a" ) + graphql. ArgInt (slot, "b" ))
end
func endpoint (ctx: i64 ):
res := graphql. HandleHttpSimple (
schema,
http. Method (ctx),
http. Header (ctx, "Content-Type" ),
http. Body (ctx),
http. RawQuery (ctx)
)
http. SetStatus (ctx, res.status)
http. SetHeader (ctx, "Content-Type" , res.contentType)
http. Text (ctx, res.body)
end
func main :
mut err := graphql. NewError (graphql.ERR_SYNTAX, "" )
graphql. ParseSchemaInto (schema, "type Query { me: String! add(a: Int!, b: Int!): Int! }" , err)
_ := graphql. SetResolver (schema, "Query" , "me" , me)
_ := graphql. SetResolver (schema, "Query" , "add" , add)
mut r := router. NewRouter ()
router. Post (r, "/graphql" , endpoint)
router. Get (r, "/graphql" , endpoint)
mut srv := http. NewServer ( 19640 )
http. Use (srv, r)
_ := http. RunBackground (srv)
mut vars := value. NewValueObject ()
value. ObjectSet (vars, "x" , value. ValueInt ( 40 ))
body := graphql. BuildRequestBody ( "query Sum($x: Int!) { add(a: $x, b: 2) }" , "Sum" , vars)
println body
mut headers := http. NewHeaders ()
headers. Insert ( "Content-Type" , "application/json" )
resp := http. PostWith ( "http://127.0.0.1:19640/graphql" , body, headers)
println http. Status (resp), http. Body (resp)
mut cr := graphql. ParseResponse (http. Body (resp))
println graphql. ResponseOk (cr), cr.hasData, value. AsInt (graphql. ResponseField (cr, "add" ))
graphql. FreeClientResponse (cr)
qs := graphql. BuildRequestQueryString ( "{ me }" , "" , value. ValueNull ())
resp2 := http. Get ( "http://127.0.0.1:19640/graphql?" + qs)
println http. Body (resp2)
resp3 := http. PostWith (
"http://127.0.0.1:19640/graphql" , graphql. BuildQueryBody ( "{ nope }" ), headers
)
mut cr3 := graphql. ParseResponse (http. Body (resp3))
println http. Status (resp3), graphql. ResponseOk (cr3), graphql. ResponseErrorMessage (cr3)
graphql. FreeClientResponse (cr3)
mut req := graphql. ParseHttpRequestJSON ( `{"query":"{ me }"}` )
mut context := value. NewValueObject ()
value. ObjectSet (context, "user" , value. ValueString ( "Maryam" ))
mut res := graphql. HandleRequest (schema, req, value. ValueNull (), context)
println graphql. ResultToJSON (res)
graphql. FreeResult (res)
graphql. FreeHttpRequest (req)
bad := graphql. ParseHttpRequest ( "PUT" , "application/json" , "{}" , "" )
println bad.ok, bad.error
resp4 := graphql. HandleHttp (
schema, "POST" , "application/json" , "not json" , "" , value. ValueNull (), value. ValueNull ()
)
println resp4.status
end Output {"query": "query Sum($x: Int!) { add(a: $x, b: 2) }", "operationName": "Sum", "variables": {"x": 40}}
200 {"data": {"add": 42}}
true true 42
{"data": {"me": "guest (Query.me)"}}
400 false cannot query field "nope" on type "Query" (line 1, column 3)
{"data": {"me": "Maryam (Query.me)"}}
false only GET and POST are supported
400
The state of one resolver call.
Name Type Description busybool = falseIn use. parentvalue.ValueThe parent. argsvalue.ValueThe arguments. ctxvalue.ValueThe context. fieldNamestr = ""The field name. parentTypestr = ""The parent type. resultvalue.ValueThe result. resolvedbool = falseThe result was set. failedbool = falseIt failed. messagestr = ""The error message.
The example for this item is shown with the ones above: graphql-Execute.salam
Name Type Description itemsVector<ResolverSlot>The slots.
The example for this item is shown with the ones above: graphql-Execute.salam
A GraphQL request over HTTP.
Name Type Description querystr = ""The query text. operationNamestr = ""The operation name. variablesvalue.ValueThe variables. extensionsvalue.ValueThe extensions. okbool = trueIt was read correctly. errorstr = ""If not, the reason.
The example for this item is shown with the ones above: graphql-Http.salam
Name Type Description statusint = 200The status code. contentTypestr = "application/json"The content type. bodystr = ""The body.
The example for this item is shown with the ones above: graphql-Http.salam
Functions
func NewError (category: int , message: str ): GqlError An error with a category and a message.
The example for this item is shown with the ones above: graphql-Schema.salam
func NewErrorAt (category: int , message: str , line: int , col: int ): GqlError An error with a line and column.
The example for this item is shown with the ones above: graphql-Document.salam
func SyntaxError (message: str , line: int , col: int ): GqlError A syntax error with a location.
The example for this item is shown with the ones above: graphql-Schema.salam
func PathPushKey (e &: GqlError, key: str ) Adds a key to the path of the error.
The example for this item is shown with the ones above: graphql-Document.salam
func PathPushIndex (e &: GqlError, idx: int ) Adds an index to the path.
The example for this item is shown with the ones above: graphql-Document.salam
func PathLen (e: GqlError): int The example for this item is shown with the ones above: graphql-Document.salam
func PathString (e: GqlError): str The path in the form books[2].title.
The example for this item is shown with the ones above: graphql-Document.salam
func AddError (list &: GqlErrorList, e: GqlError) Adds an error to the list; the list owns the error from then on, so do not free it separately.
The example for this item is shown with the ones above: graphql-Document.salam
func HasErrors (list: GqlErrorList): bool The example for this item is shown with the ones above: graphql-Document.salam
func ErrorCount (list: GqlErrorList): int How many errors there are.
The example for this item is shown with the ones above: graphql-Document.salam
func ErrorAt (list: GqlErrorList, i: int ): GqlError The example for this item is shown with the ones above: graphql-Document.salam
func ErrorString (e: GqlError): str The text of the error with its location and path.
The example for this item is shown with the ones above: graphql-Document.salam
func ErrorToValue (e: GqlError): value.Value The error as a value for a JSON response.
The example for this item is shown with the ones above: graphql-Document.salam
func ErrorsToValue (list: GqlErrorList): value.Value The list of errors as an array.
The example for this item is shown with the ones above: graphql-Document.salam
func FreeError (e &: GqlError) The example for this item is shown with the ones above: graphql-Document.salam
func FreeErrorList (list &: GqlErrorList) Frees the list and all its errors.
The example for this item is shown with the ones above: graphql-Document.salam
func TokenKindName (kind: int ): str The name of a token kind.
The example for this item is shown with the ones above: graphql-Document.salam
func IsStringToken (kind: int ): bool The kind is a string or a block string.
The example for this item is shown with the ones above: graphql-Document.salam
func Execute (sch: Schema, doc: Document, operationName: str , variables: value.Value, rootValue: value.Value, ctx: value.Value): ExecutionResult Runs a parsed document with an operation name, variables, a root value and a context.
The example for this item is shown with the ones above: graphql-Document.salam
func ExecuteSource (sch: Schema, source: str , operationName: str , variables: value.Value, rootValue: value.Value, ctx: value.Value): ExecutionResult Like the function above, from text.
The example for this item is shown with the ones above: graphql-Execute.salam
func Run (sch: Schema, source: str ): ExecutionResult Runs the text without variables.
The example for this item is shown with the ones above: graphql-Execute.salam
func SetExtensions (r &: ExecutionResult, ext: value.Value) Sets the extensions of the result.
The example for this item is shown with the ones above: graphql-Internals.salam
func ResultToValue (r: ExecutionResult): value.Value The example for this item is shown with the ones above: graphql-Internals.salam
func ResultToJSON (r: ExecutionResult): str The example for this item is shown with the ones above: graphql-Execute.salam
func ResultToJSONIndent (r: ExecutionResult): str Readable JSON with indentation.
The example for this item is shown with the ones above: graphql-Internals.salam
func ResultToJSONStable (r: ExecutionResult): str JSON with sorted keys; for tests and comparisons.
The example for this item is shown with the ones above: graphql-Execute.salam
func ResultOk (r: ExecutionResult): bool The example for this item is shown with the ones above: graphql-Execute.salam
func ResultErrorMessage (r: ExecutionResult): str The message of the first error.
The example for this item is shown with the ones above: graphql-Execute.salam
func FreeResult (r &: ExecutionResult) The example for this item is shown with the ones above: graphql-Execute.salam
An empty schema with the standard scalar types and directives.
The example for this item is shown with the ones above: graphql-Schema.salam
func TypeRefText (sch &: Schema, text: str ): int Registers type reference text, such as [Int!], in the schema and returns its number.
The example for this item is shown with the ones above: graphql-Schema.salam
func AddScalarType (sch &: Schema, name: str , description: str ) The example for this item is shown with the ones above: graphql-Schema.salam
func AddObjectType (sch &: Schema, name: str , description: str ) The example for this item is shown with the ones above: graphql-Schema.salam
func AddInterfaceType (sch &: Schema, name: str , description: str ) The example for this item is shown with the ones above: graphql-Schema.salam
func AddInputObjectType (sch &: Schema, name: str , description: str ) The example for this item is shown with the ones above: graphql-Schema.salam
func AddEnumType (sch &: Schema, name: str , values: Vector < str >) An enum type with its values.
The example for this item is shown with the ones above: graphql-Schema.salam
func AddUnionType (sch &: Schema, name: str , members: Vector < str >) A union with its members.
The example for this item is shown with the ones above: graphql-Schema.salam
func AddInterfaceTo (sch &: Schema, typeName: str , interfaceName: str ) Adds an interface to the interface list of a type.
The example for this item is shown with the ones above: graphql-Schema.salam
func AddField (sch &: Schema, typeName: str , fieldName: str , typeText: str ): bool Adds a field with type text such as [Book!]!.
The example for this item is shown with the ones above: graphql-Schema.salam
func AddFieldArg (sch &: Schema, typeName: str , fieldName: str , argName: str , typeText: str ): bool Adds an argument to a field.
The example for this item is shown with the ones above: graphql-Schema.salam
func AddInputField (sch &: Schema, typeName: str , fieldName: str , typeText: str ): bool Adds a field to an input type.
The example for this item is shown with the ones above: graphql-Schema.salam
func SetRootTypes (sch &: Schema, queryType: str , mutationType: str , subscriptionType: str ) Sets the root types; an empty string means there is none.
The example for this item is shown with the ones above: graphql-Schema.salam
func FreeSchema (sch &: Schema) The example for this item is shown with the ones above: graphql-Schema.salam
func Validate (sch: Schema, doc: Document): GqlErrorList Validates the document against the schema: missing fields, argument types, undefined variables and the like.
The example for this item is shown with the ones above: graphql-Document.salam
func ValidateOk (sch: Schema, doc: Document): bool The example for this item is shown with the ones above: graphql-Document.salam
func ValidateSource (sch: Schema, source: str ): GqlErrorList Parses and validates the text.
The example for this item is shown with the ones above: graphql-Document.salam
func CollectFields (sch: Schema, doc: Document, sels: Vector < int >, objectType: str , vars: value.Value): FieldGroups Turns selections into groups by response key, following fragments and the include and skip directives.
The example for this item is shown with the ones above: graphql-Internals.salam
func MergeSelections (doc: Document, g: FieldGroup): Vector < int > Merges the sub selections of a group into one.
The example for this item is shown with the ones above: graphql-Internals.salam
func FreeFieldGroups (gs &: FieldGroups) The example for this item is shown with the ones above: graphql-Internals.salam
func PrintSchema (sch: Schema): str Turns the schema back into SDL, without the built in types.
The example for this item is shown with the ones above: graphql-Schema.salam
func PrintSchemaFull (sch: Schema): str Turns the schema into SDL with the built in types.
The example for this item is shown with the ones above: graphql-Schema.salam
func PrintType (sch: Schema, name: str ): str The example for this item is shown with the ones above: graphql-Schema.salam
func SelectionAt (doc: Document, id: int ): AstSelection The selection with this number.
The example for this item is shown with the ones above: graphql-Document.salam
func ValueAt (doc: Document, id: int ): AstValue The value with this number.
The example for this item is shown with the ones above: graphql-Document.salam
func TypeRefAt (doc: Document, id: int ): AstTypeRef The type reference with this number.
The example for this item is shown with the ones above: graphql-Document.salam
func FindOperation (doc: Document, name: str ): int The number of the operation with this name; an empty name means the only operation. -1 when there is none.
The example for this item is shown with the ones above: graphql-Document.salam
func FindFragment (doc: Document, name: str ): int The number of the fragment with this name.
The example for this item is shown with the ones above: graphql-Document.salam
func OperationTypeName (optype: int ): str The name of the operation: query, mutation or subscription.
The example for this item is shown with the ones above: graphql-Document.salam
func ResponseKey (sel: AstSelection): str The key of a selection in the response: the alias, or the field name when there is none.
The example for this item is shown with the ones above: graphql-Document.salam
func FreeDocument (doc &: Document) The example for this item is shown with the ones above: graphql-Document.salam
func TypeRefIsNonNull (doc: Document, id: int ): bool The reference is non null.
The example for this item is shown with the ones above: graphql-Document.salam
func TypeRefIsList (doc: Document, id: int ): bool The example for this item is shown with the ones above: graphql-Document.salam
func TypeRefElement (doc: Document, id: int ): int The reference of the list element.
The example for this item is shown with the ones above: graphql-Internals.salam
func TypeRefName (doc: Document, id: int ): str The name of the base type, without the list and the !.
The example for this item is shown with the ones above: graphql-Document.salam
func FindType (s: Schema, name: str ): TypeDef The definition of the type with this name.
The example for this item is shown with the ones above: graphql-Schema.salam
func HasType (s: Schema, name: str ): bool The example for this item is shown with the ones above: graphql-Schema.salam
func TypeIndex (s: Schema, name: str ): int The number of the type; -1 when there is none.
The example for this item is shown with the ones above: graphql-Schema.salam
func TypeCount (s: Schema): int How many types there are.
The example for this item is shown with the ones above: graphql-Schema.salam
func TypeAt (s: Schema, i: int ): TypeDef The example for this item is shown with the ones above: graphql-Schema.salam
func FindField (t: TypeDef, name: str ): FieldDef The example for this item is shown with the ones above: graphql-Schema.salam
func HasField (t: TypeDef, name: str ): bool The example for this item is shown with the ones above: graphql-Schema.salam
func FindInputField (t: TypeDef, name: str ): InputValueDef A field of an input type.
The example for this item is shown with the ones above: graphql-Schema.salam
func FindArg (f: FieldDef, name: str ): InputValueDef The example for this item is shown with the ones above: graphql-Schema.salam
func FindDirectiveDef (s: Schema, name: str ): DirectiveDef The definition of a directive.
The example for this item is shown with the ones above: graphql-Schema.salam
func HasEnumValue (t: TypeDef, name: str ): bool The enum type has this value.
The example for this item is shown with the ones above: graphql-Schema.salam
func IsInputType (s: Schema, name: str ): bool The type is allowed in inputs.
The example for this item is shown with the ones above: graphql-Schema.salam
func IsOutputType (s: Schema, name: str ): bool The type is allowed in outputs.
The example for this item is shown with the ones above: graphql-Schema.salam
func IsAbstractType (s: Schema, name: str ): bool It is an interface or a union.
The example for this item is shown with the ones above: graphql-Schema.salam
func IsLeafType (s: Schema, name: str ): bool It is a scalar or an enum.
The example for this item is shown with the ones above: graphql-Schema.salam
func IsPossibleType (s: Schema, abstractName: str , objectName: str ): bool The object type can stand in for this interface or union.
The example for this item is shown with the ones above: graphql-Schema.salam
func PossibleTypes (s: Schema, name: str ): Vector < str > The object types that can stand in for an interface or union.
The example for this item is shown with the ones above: graphql-Schema.salam
func RootTypeName (s: Schema, optype: int ): str The name of the root type of an operation.
The example for this item is shown with the ones above: graphql-Schema.salam
func PrintStringValue (s: str ): str Returns the string as an escaped GraphQL string.
The example for this item is shown with the ones above: graphql-Document.salam
func PrintTypeRef (doc: Document, id: int ): str The text of one type reference.
The example for this item is shown with the ones above: graphql-Document.salam
func PrintValue (doc: Document, id: int ): str The text of one value of the document.
The example for this item is shown with the ones above: graphql-Document.salam
func Print (doc: Document): str Turns the document back into tidy text.
The example for this item is shown with the ones above: graphql-Schema.salam
func IsIntrospectionType (name: str ): bool The name is one of the introspection types, such as __Type.
The example for this item is shown with the ones above: graphql-Schema.salam
func AddIntrospectionTypes (sch &: Schema) Adds the introspection types to the schema so that __schema queries work.
The example for this item is shown with the ones above: graphql-Schema.salam
func LiteralToValue (sch: Schema, doc: Document, valueId: int , vars: value.Value): CoerceResult Turns a value of the document into an encoding value, filling in the variables.
The example for this item is shown with the ones above: graphql-Internals.salam
func CoerceInput (sch: Schema, refDoc: Document, typeRef: int , v: value.Value): CoerceResult Makes an input value fit the given type.
The example for this item is shown with the ones above: graphql-Internals.salam
func CoerceLeafResult (sch: Schema, typeName: str , v: value.Value): CoerceResult Makes the output of a resolver fit a leaf type, such as Int or an enum.
The example for this item is shown with the ones above: graphql-Document.salam
func BuildRequestBody (queryText: str , operationName: str , variables: value.Value): str The JSON body of a POST request.
The example for this item is shown with the ones above: graphql-Http.salam
func BuildQueryBody (queryText: str ): str A JSON body with only the query.
The example for this item is shown with the ones above: graphql-Http.salam
func BuildRequestQueryString (queryText: str , operationName: str , variables: value.Value): str The query string for a GET request.
The example for this item is shown with the ones above: graphql-Http.salam
func ParseResponse (body: str ): ClientResponse Reads the JSON response of the server.
The example for this item is shown with the ones above: graphql-Http.salam
func ResponseField (r: ClientResponse, name: str ): value.Value A field of the response data.
The example for this item is shown with the ones above: graphql-Http.salam
func ResponseOk (r: ClientResponse): bool The response has no errors.
The example for this item is shown with the ones above: graphql-Http.salam
func ResponseErrorMessage (r: ClientResponse): str The message of the first error.
The example for this item is shown with the ones above: graphql-Http.salam
func FreeClientResponse (r &: ClientResponse) The example for this item is shown with the ones above: graphql-Http.salam
func SetResolver (sch &: Schema, typeName: str , fieldName: str , fn: i64 ): bool Registers a function for a field of a type; the function takes the slot number. A field without a resolver returns the value of the same name from the parent object.
The example for this item is shown with the ones above: graphql-Execute.salam
func HasResolver (sch: Schema, typeName: str , fieldName: str ): bool The field has a resolver.
The example for this item is shown with the ones above: graphql-Execute.salam
func Parent (slot: i64 ): value.Value The example for this item is shown with the ones above: graphql-Execute.salam
func Args (slot: i64 ): value.Value The arguments as an object.
The example for this item is shown with the ones above: graphql-Internals.salam
func Context (slot: i64 ): value.Value The context given to the execution; the signed in user, for instance.
The example for this item is shown with the ones above: graphql-Http.salam
func FieldName (slot: i64 ): str The example for this item is shown with the ones above: graphql-Http.salam
func ParentTypeName (slot: i64 ): str The name of the parent type.
The example for this item is shown with the ones above: graphql-Http.salam
func HasArg (slot: i64 , name: str ): bool The example for this item is shown with the ones above: graphql-Execute.salam
func Arg (slot: i64 , name: str ): value.Value The example for this item is shown with the ones above: graphql-Execute.salam
func ArgInt (slot: i64 , name: str ): i64 The example for this item is shown with the ones above: graphql-Execute.salam
func ArgFloat (slot: i64 , name: str ): f64 The example for this item is shown with the ones above: graphql-Execute.salam
func ArgStr (slot: i64 , name: str ): str The example for this item is shown with the ones above: graphql-Execute.salam
func ArgBool (slot: i64 , name: str ): bool The example for this item is shown with the ones above: graphql-Execute.salam
func ParentField (slot: i64 , name: str ): value.Value A field of the parent object.
The example for this item is shown with the ones above: graphql-Execute.salam
func Resolve (slot: i64 , v: value.Value) Sets the result to a value.
The example for this item is shown with the ones above: graphql-Execute.salam
func ResolveInt (slot: i64 , n: i64 ) The example for this item is shown with the ones above: graphql-Execute.salam
func ResolveFloat (slot: i64 , f: f64 ) The example for this item is shown with the ones above: graphql-Execute.salam
func ResolveStr (slot: i64 , s: str ) The example for this item is shown with the ones above: graphql-Execute.salam
func ResolveBool (slot: i64 , b: bool ) The example for this item is shown with the ones above: graphql-Execute.salam
func ResolveNull (slot: i64 ) The example for this item is shown with the ones above: graphql-Execute.salam
func Fail (slot: i64 , message: str ) Ends the field with an error; the field becomes null and the error comes back in the response with its path.
The example for this item is shown with the ones above: graphql-Execute.salam
Frees the resolver slots.
The example for this item is shown with the ones above: graphql-Execute.salam
func Tokenize (source: str , ok &: bool ): GqlTokenStream Breaks the text into tokens.
The example for this item is shown with the ones above: graphql-Document.salam
func LexOk (source: str ): bool The text has no lexical errors.
The example for this item is shown with the ones above: graphql-Document.salam
func ParseHttpRequest (method: str , contentType: str , body: str , queryString: str ): GqlHttpRequest Reads the request from the method, the content type, the body and the query string; GET, and POST with JSON or application/graphql.
The example for this item is shown with the ones above: graphql-Http.salam
func ParseHttpRequestJSON (body: str ): GqlHttpRequest The example for this item is shown with the ones above: graphql-Http.salam
func HandleRequest (sch: Schema, req: GqlHttpRequest, rootValue: value.Value, ctx: value.Value): ExecutionResult Runs a request that was already read.
The example for this item is shown with the ones above: graphql-Http.salam
func HandleHttp (sch: Schema, method: str , contentType: str , body: str , queryString: str , rootValue: value.Value, ctx: value.Value): GqlHttpResponse Handles an HTTP request from the raw input to the finished response, with a root value and a context.
The example for this item is shown with the ones above: graphql-Http.salam
func HandleHttpSimple (sch: Schema, method: str , contentType: str , body: str , queryString: str ): GqlHttpResponse Like the function above, without a root value or a context.
The example for this item is shown with the ones above: graphql-Http.salam
func FreeHttpRequest (req &: GqlHttpRequest) The example for this item is shown with the ones above: graphql-Http.salam
func Parse (source: str , err &: GqlError): Document Parses a query document; when the syntax is wrong, the error is filled in.
The example for this item is shown with the ones above: graphql-Schema.salam
func ParseOk (source: str ): bool The example for this item is shown with the ones above: graphql-Document.salam
func ParseSchema (source: str , err &: GqlError): Schema Builds a schema from SDL text.
The example for this item is shown with the ones above: graphql-Schema.salam
func ParseSchemaInto (sch &: Schema, source: str , err &: GqlError) Adds SDL text, extend type included, to an existing schema.
The example for this item is shown with the ones above: graphql-Schema.salam
func ParseSchemaOk (source: str ): bool The example for this item is shown with the ones above: graphql-Schema.salam