func getFieldDef( schema typs.QLSchema, parentType *typs.QLObject, fieldName string, ) *typs.QLFieldDefinition { if fieldName == typs.SchemaMetaFieldDef.Name && schema.GetQueryType() == parentType { return typs.SchemaMetaFieldDef } if fieldName == typs.TypeMetaFieldDef.Name && schema.GetQueryType() == parentType { return typs.TypeMetaFieldDef } if fieldName == typs.TypeNameMetaFieldDef.Name { return typs.TypeNameMetaFieldDef } return parentType.GetFields()[fieldName] }
func getOperationRootType( schema typs.QLSchema, operation *lang.OperationDefinition, ) *typs.QLObject { switch operation.Operation { case lang.OperationQuery: return schema.GetQueryType() case lang.OperationMutation: murationType := schema.GetMutationType() if murationType == nil { panic(lang.NewQLError( "Schema is not configured for mutations", []lang.INode{operation})) } return murationType default: panic(lang.NewQLError( "Can only execute queries and mutation", []lang.INode{operation})) } }
func TypeFromAST(schema typs.QLSchema, inputTypeAST lang.IType) typs.QLType { switch typ := inputTypeAST.(type) { case *lang.ListType: innerType := TypeFromAST(schema, typ.Type) if innerType == nil { return nil } return typs.NewQLList(innerType) case *lang.NonNullType: innerType := TypeFromAST(schema, typ.Type) if innerType == nil { return nil } return typs.NewQLNonNull(innerType) case *lang.NamedType: return schema.GetType(typ.Name.Value) default: throw("Must be a named type.") return nil } }