//export processEndVisitField func processEndVisitField(node *C.struct_GraphQLAstField, parser unsafe.Pointer) { p := (*Parser)(parser) field := p.nodes.Head().(*graphql.Selection) if field.Field != nil { alias := C.GraphQLAstField_get_alias(node) if alias != nil { field.Field.Alias = C.GoString(C.GraphQLAstName_get_value(alias)) } name := C.GraphQLAstField_get_name(node) if name != nil { field.Field.Name = C.GoString(C.GraphQLAstName_get_value(name)) } p.endVisitNode() } }
//export processEndVisitObjectField func processEndVisitObjectField(node *C.struct_GraphQLAstObjectField, parser unsafe.Pointer) { p := (*Parser)(parser) field := make(map[string]interface{}, 1) name := C.GraphQLAstObjectField_get_name(node) value := p.endVisitNode() field[C.GoString(C.GraphQLAstName_get_value(name))] = value p.visitNode(field) }
//export processEndVisitFragmentDefinition func processEndVisitFragmentDefinition(node *C.struct_GraphQLAstFragmentDefinition, parser unsafe.Pointer) { p := (*Parser)(parser) fragment := p.nodes.Head().(*graphql.FragmentDefinition) condition := C.GraphQLAstFragmentDefinition_get_type_condition(node) condition_name := C.GraphQLAstNamedType_get_name(condition) fragment.TypeCondition = C.GoString(C.GraphQLAstName_get_value(condition_name)) p.endVisitNode() }
//export processEndVisitDirective func processEndVisitDirective(node *C.struct_GraphQLAstDirective, parser unsafe.Pointer) { p := (*Parser)(parser) directive := p.nodes.Head().(*graphql.Directive) name := C.GraphQLAstDirective_get_name(node) if name != nil { directive.Name = C.GoString(C.GraphQLAstName_get_value(name)) } p.endVisitNode() }
//export processEndVisitVariable func processEndVisitVariable(node *C.struct_GraphQLAstVariable, parser unsafe.Pointer) { p := (*Parser)(parser) variable := &graphql.Variable{} name := C.GraphQLAstVariable_get_name(node) if name != nil { variable.Name = C.GoString(C.GraphQLAstName_get_value(name)) } p.visitNode(variable) }
//export processEndVisitOperationDefinition func processEndVisitOperationDefinition(node *C.struct_GraphQLAstOperationDefinition, parser unsafe.Pointer) { p := (*Parser)(parser) operation := p.nodes.Head().(*graphql.Operation) name := C.GraphQLAstOperationDefinition_get_name(node) if name != nil { operation.Name = C.GoString(C.GraphQLAstName_get_value(name)) } operation.Type = graphql.OperationType(C.GoString(C.GraphQLAstOperationDefinition_get_operation(node))) p.endVisitNode() }
//export processVisitFragmentDefinition func processVisitFragmentDefinition(node *C.struct_GraphQLAstFragmentDefinition, parser unsafe.Pointer) int { p := (*Parser)(parser) doc := p.nodes.Head().(*graphql.Document) name := C.GraphQLAstFragmentDefinition_get_name(node) fragment := &graphql.FragmentDefinition{ Name: C.GoString(C.GraphQLAstName_get_value(name)), } doc.FragmentDefinitions = append(doc.FragmentDefinitions, fragment) p.visitNode(fragment) return 1 }
//export processEndVisitArgument func processEndVisitArgument(node *C.struct_GraphQLAstArgument, parser unsafe.Pointer) { p := (*Parser)(parser) name := C.GraphQLAstArgument_get_name(node) value := p.endVisitNode() argument := graphql.Argument{ Name: C.GoString(C.GraphQLAstName_get_value(name)), Value: value, } selection, ok := p.nodes.Head().(*graphql.Selection) if ok { selection.Field.Arguments = append(selection.Field.Arguments, argument) } directive, ok := p.nodes.Head().(*graphql.Directive) if ok { directive.Arguments = append(directive.Arguments, argument) } }
//export processVisitFragmentSpread func processVisitFragmentSpread(node *C.struct_GraphQLAstFragmentSpread, parser unsafe.Pointer) int { p := (*Parser)(parser) name := C.GraphQLAstFragmentSpread_get_name(node) selection := &graphql.Selection{ FragmentSpread: &graphql.FragmentSpread{ Name: C.GoString(C.GraphQLAstName_get_value(name)), }, } operation, ok := p.nodes.Head().(*graphql.Operation) if ok { operation.SelectionSet = append(operation.SelectionSet, selection) } parent, ok := p.nodes.Head().(*graphql.Selection) if ok { parent.Field.SelectionSet = append(parent.Field.SelectionSet, selection) } fragDefinition, ok := p.nodes.Head().(*graphql.FragmentDefinition) if ok { fragDefinition.SelectionSet = append(fragDefinition.SelectionSet, selection) } return 0 }
//export processEndVisitVariableDefinition func processEndVisitVariableDefinition(node *C.struct_GraphQLAstVariableDefinition, parser unsafe.Pointer) { var variable *graphql.VariableDefinition var ok bool p := (*Parser)(parser) last1 := p.endVisitNode() last2 := p.endVisitNode() last3 := p.endVisitNode() value, ok := last1.(*graphql.Value) if ok { variable, ok = last3.(*graphql.VariableDefinition) variable.Variable = last2.(*graphql.Variable) variable.DefaultValue = value } else { p.visitNode(last3) variable, ok = last2.(*graphql.VariableDefinition) variable.Variable = last1.(*graphql.Variable) } typeT := (*C.struct_GraphQLAstNamedType)(C.GraphQLAstVariableDefinition_get_type(node)) typeName := C.GraphQLAstNamedType_get_name(typeT) variable.Type.Name = C.GoString(C.GraphQLAstName_get_value(typeName)) }
//export printField func printField(field *C.struct_GraphQLAstField, unused unsafe.Pointer) int { fmt.Printf("field : %s\n", C.GoString(C.GraphQLAstName_get_value(C.GraphQLAstField_get_name(field)))) return 0 }