identify and ignore network refs in graphqlapi
@@ -22,6 +22,7 @@ import (
"github.com/creativesoftwarefdn/weaviate/graphqlapi/descriptions"
"github.com/creativesoftwarefdn/weaviate/graphqlapi/local/common_filters"
"github.com/creativesoftwarefdn/weaviate/models"
+ "github.com/creativesoftwarefdn/weaviate/network/crossrefs"
"github.com/davecgh/go-spew/spew"
"github.com/graphql-go/graphql"
graphql_ast "github.com/graphql-go/graphql/language/ast"
@@ -35,20 +36,6 @@ func Build(dbSchema *schema.Schema) (*graphql.Field, error) {
}
knownClasses := map[string]*graphql.Object{}
- knownClasses["WeaviateB/Instrument"] = graphql.NewObject(graphql.ObjectConfig{
- Name: "WeaviateBInstrument",
- Fields: graphql.Fields{
- "foo": &graphql.Field{
- Name: "foo",
- Type: graphql.String,
- Resolve: func(q graphql.ResolveParams) (interface{}, error) {
- return "fooobarbaz", nil
- },
- },
- },
- })
-
- // TODO remove hard-coded test class:
if len(dbSchema.Actions.Classes) > 0 {
localGetActions, err := buildGetClasses(dbSchema, kind.ACTION_KIND, dbSchema.Actions, &knownClasses)
@@ -206,16 +193,21 @@ func buildGetClass(dbSchema *schema.Schema, k kind.Kind, kindName string, class
// This is a reference
refClasses := propertyType.Classes()
propertyName := strings.Title(property.Name)
- dataTypeClasses := make([]*graphql.Object, len(refClasses))
+ dataTypeClasses := []*graphql.Object{}
- for index, refClassName := range refClasses {
+ for _, refClassName := range refClasses {
refClass, ok := (*knownClasses)[string(refClassName)]
+ if crossrefs.ValidClassName(string(refClassName)) {
+ // simply ignore all network cross-refs for now
+ continue
+ }
+
if !ok {
panic(fmt.Sprintf("buildGetClass: unknown referenced class type for %s.%s.%s; %s", k.Name(), class.Class, property.Name, refClassName))
}
- dataTypeClasses[index] = refClass
+ dataTypeClasses = append(dataTypeClasses, refClass)
}
classUnion := graphql.NewUnion(graphql.UnionConfig{
@@ -224,8 +216,6 @@ func buildGetClass(dbSchema *schema.Schema, k kind.Kind, kindName string, class
ResolveType: func(p graphql.ResolveTypeParams) *graphql.Object {
// TODO: inspect type of result.
return (*knownClasses)["City"]
- fmt.Printf("Resolver: WHOOPTYDOO\n")
- return nil
},
Description: property.Description,
})
@@ -342,12 +332,10 @@ func extractProperties(selections *graphql_ast.SelectionSet) ([]SelectProperty,
var className schema.ClassName
var err error
- if fragment.TypeCondition.Name.Value != "WeaviateBInstrument" {
err, className = schema.ValidateClassName(fragment.TypeCondition.Name.Value)
if err != nil {
return nil, fmt.Errorf("The inline fragment type name '%s' is not a valid class name.", fragment.TypeCondition.Name.Value)
}
- }
subProperties, err := extractProperties(fragment.SelectionSet)
if err != nil {
