Skip to content

Commit

Permalink
Merge branch 'sogko/0.5.0' into sogko/experiment-parallel-resolve
Browse files Browse the repository at this point in the history
* sogko/0.5.0: (32 commits)
  RFC: Return type overlap validation
  Tests for `NewDirectives()` for better coverage
  Clean up redundant code in `completeValueCatchingError` - `completeValue` would already have resolved the value for `func() interface{}`
  Add tests for type comparators
  Spec compliant @skip/@include.
  Fix bug where @include directive is ignored if @Skip is present.
  Test that `executor` threads `RootValue` correctly - Similar to `context` test
  Improve coercion error messages
  [RFC] Add explicit context arg to graphql execution
  Add GraphQLSchema types field
  Removed logs
  Follow up to: Move getTypeOf to executor and rename to defaultResolveTypeFn to mirror defaultResolveFn
  Add tests for default resolve function.
  Restored deprecated fields in `directives` in introspective query for coverage. Should be removed once `onOperation`, `onFragment`, `onField` are dropped from spec.
  Move getTypeOf to execute.js and rename to defaultResolveTypeFn to mirror defaultResolveFn
  Remove unused function parameters
  Remove unused function parameters
  Minor follow-up to #311
  [RFC] Add Schema Definition to IDL.
  Updating schema parser to more closely match current state of RFC
  ...
  • Loading branch information
sogko committed May 31, 2016
2 parents ab3b083 + 34413d2 commit 2dcd77e
Show file tree
Hide file tree
Showing 39 changed files with 2,698 additions and 1,343 deletions.
80 changes: 22 additions & 58 deletions abstract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) {
})

// ie declare that Dog belongs to Pet interface
_ = graphql.NewObject(graphql.ObjectConfig{
dogType := graphql.NewObject(graphql.ObjectConfig{
Name: "Dog",
Interfaces: []*graphql.Interface{
petType,
},
IsTypeOf: func(value interface{}, info graphql.ResolveInfo) bool {
_, ok := value.(*testDog)
IsTypeOf: func(p graphql.IsTypeOfParams) bool {
_, ok := p.Value.(*testDog)
return ok
},
Fields: graphql.Fields{
Expand All @@ -67,13 +67,13 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) {
},
})
// ie declare that Cat belongs to Pet interface
_ = graphql.NewObject(graphql.ObjectConfig{
catType := graphql.NewObject(graphql.ObjectConfig{
Name: "Cat",
Interfaces: []*graphql.Interface{
petType,
},
IsTypeOf: func(value interface{}, info graphql.ResolveInfo) bool {
_, ok := value.(*testCat)
IsTypeOf: func(p graphql.IsTypeOfParams) bool {
_, ok := p.Value.(*testCat)
return ok
},
Fields: graphql.Fields{
Expand Down Expand Up @@ -112,6 +112,7 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) {
},
},
}),
Types: []graphql.Type{catType, dogType},
})
if err != nil {
t.Fatalf("Error in schema %v", err.Error())
Expand Down Expand Up @@ -161,8 +162,8 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForUnion(t *testing.T) {

dogType := graphql.NewObject(graphql.ObjectConfig{
Name: "Dog",
IsTypeOf: func(value interface{}, info graphql.ResolveInfo) bool {
_, ok := value.(*testDog)
IsTypeOf: func(p graphql.IsTypeOfParams) bool {
_, ok := p.Value.(*testDog)
return ok
},
Fields: graphql.Fields{
Expand All @@ -176,8 +177,8 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForUnion(t *testing.T) {
})
catType := graphql.NewObject(graphql.ObjectConfig{
Name: "Cat",
IsTypeOf: func(value interface{}, info graphql.ResolveInfo) bool {
_, ok := value.(*testCat)
IsTypeOf: func(p graphql.IsTypeOfParams) bool {
_, ok := p.Value.(*testCat)
return ok
},
Fields: graphql.Fields{
Expand Down Expand Up @@ -269,14 +270,14 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
Type: graphql.String,
},
},
ResolveType: func(value interface{}, info graphql.ResolveInfo) *graphql.Object {
if _, ok := value.(*testCat); ok {
ResolveType: func(p graphql.ResolveTypeParams) *graphql.Object {
if _, ok := p.Value.(*testCat); ok {
return catType
}
if _, ok := value.(*testDog); ok {
if _, ok := p.Value.(*testDog); ok {
return dogType
}
if _, ok := value.(*testHuman); ok {
if _, ok := p.Value.(*testHuman); ok {
return humanType
}
return nil
Expand All @@ -288,12 +289,6 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
Fields: graphql.Fields{
"name": &graphql.Field{
Type: graphql.String,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
if human, ok := p.Source.(*testHuman); ok {
return human.Name, nil
}
return nil, nil
},
},
},
})
Expand All @@ -302,28 +297,12 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
Interfaces: []*graphql.Interface{
petType,
},
IsTypeOf: func(value interface{}, info graphql.ResolveInfo) bool {
_, ok := value.(*testDog)
return ok
},
Fields: graphql.Fields{
"name": &graphql.Field{
Type: graphql.String,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
if dog, ok := p.Source.(*testDog); ok {
return dog.Name, nil
}
return nil, nil
},
},
"woofs": &graphql.Field{
Type: graphql.Boolean,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
if dog, ok := p.Source.(*testDog); ok {
return dog.Woofs, nil
}
return nil, nil
},
},
},
})
Expand All @@ -332,28 +311,12 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
Interfaces: []*graphql.Interface{
petType,
},
IsTypeOf: func(value interface{}, info graphql.ResolveInfo) bool {
_, ok := value.(*testCat)
return ok
},
Fields: graphql.Fields{
"name": &graphql.Field{
Type: graphql.String,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
if cat, ok := p.Source.(*testCat); ok {
return cat.Name, nil
}
return nil, nil
},
},
"meows": &graphql.Field{
Type: graphql.Boolean,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
if cat, ok := p.Source.(*testCat); ok {
return cat.Meows, nil
}
return nil, nil
},
},
},
})
Expand All @@ -373,6 +336,7 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
},
},
}),
Types: []graphql.Type{catType, dogType},
})
if err != nil {
t.Fatalf("Error in schema %v", err.Error())
Expand Down Expand Up @@ -405,7 +369,7 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
},
},
Errors: []gqlerrors.FormattedError{
gqlerrors.FormattedError{
{
Message: `Runtime Object type "Human" is not a possible type for "Pet".`,
Locations: []location.SourceLocation{},
},
Expand Down Expand Up @@ -461,14 +425,14 @@ func TestResolveTypeOnUnionYieldsUsefulError(t *testing.T) {
Types: []*graphql.Object{
dogType, catType,
},
ResolveType: func(value interface{}, info graphql.ResolveInfo) *graphql.Object {
if _, ok := value.(*testCat); ok {
ResolveType: func(p graphql.ResolveTypeParams) *graphql.Object {
if _, ok := p.Value.(*testCat); ok {
return catType
}
if _, ok := value.(*testDog); ok {
if _, ok := p.Value.(*testDog); ok {
return dogType
}
if _, ok := value.(*testHuman); ok {
if _, ok := p.Value.(*testHuman); ok {
return humanType
}
return nil
Expand Down Expand Up @@ -523,7 +487,7 @@ func TestResolveTypeOnUnionYieldsUsefulError(t *testing.T) {
},
},
Errors: []gqlerrors.FormattedError{
gqlerrors.FormattedError{
{
Message: `Runtime Object type "Human" is not a possible type for "Pet".`,
Locations: []location.SourceLocation{},
},
Expand Down
Loading

0 comments on commit 2dcd77e

Please sign in to comment.