-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.go
More file actions
29 lines (23 loc) · 768 Bytes
/
Copy pathinterfaces.go
File metadata and controls
29 lines (23 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package groot
import (
"reflect"
"github.com/graphql-go/graphql"
"github.com/shreyas44/groot/parser"
)
type InterfaceType = parser.InterfaceType
func NewInterface(parserInterface *parser.Interface, builder *SchemaBuilder) *graphql.Interface {
// TODO: description
interface_ := graphql.NewInterface(graphql.InterfaceConfig{
Name: parserInterface.Name(),
Fields: graphql.Fields{},
ResolveType: func(p graphql.ResolveTypeParams) *graphql.Object {
valueType := reflect.TypeOf(p.Value)
return builder.reflectGrootMap[valueType].(*graphql.Object)
},
})
builder.addType(parserInterface, interface_)
for _, field := range parserInterface.Fields() {
interface_.AddFieldConfig(field.JSONName(), NewField(field, builder))
}
return interface_
}