Skip to content

Port changes from graphql-js v0.5.0 (April 2016 spec) #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Jun 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
83c913f
Add test for parseLiteral on ComplexScalar
sogko Apr 18, 2016
0e4b18c
correct misspellings, gofmt
kmulvey May 13, 2016
027e6f6
Merge branch 'master' into sogko/0.5.0
sogko May 30, 2016
c223119
Extract completeListValue function from CompleteValue
sogko May 30, 2016
da4f176
Extract completeLeafValue from completeValue
sogko May 30, 2016
20e82a8
Update documentation for completeLeafValue and completeListValue
sogko May 30, 2016
89b14fe
Extract completeObjectValue from completeValue
sogko May 30, 2016
3ca6410
Extract completeAbstractValue from completeValue
sogko May 30, 2016
2f15386
Add invariant for unreachable condition
sogko May 30, 2016
4fb792e
Fix error message for missing operation
sogko May 30, 2016
58f2928
[RFC] Proposed change to directive location introspection
sogko May 30, 2016
2f40572
Fix error message for missing operation with tests to confirm error
sogko May 30, 2016
2322d25
[RFC] Directives in schema language
sogko May 30, 2016
d66b3f3
Updating schema parser to more closely match current state of RFC
sogko May 30, 2016
e23ac77
[RFC] Add Schema Definition to IDL.
sogko May 30, 2016
d7a15e0
Minor follow-up to #311
sogko May 30, 2016
574088c
Remove unused function parameters
sogko May 30, 2016
d46d545
Remove unused function parameters
sogko May 31, 2016
03b92b0
Move getTypeOf to execute.js and rename to defaultResolveTypeFn to mi…
sogko May 31, 2016
7b02978
Restored deprecated fields in `directives` in introspective query for…
sogko May 31, 2016
cb9b512
Add tests for default resolve function.
sogko May 31, 2016
3571f4f
Follow up to: Move getTypeOf to executor and rename to defaultResolve…
sogko May 31, 2016
4cafaaf
Removed logs
sogko May 31, 2016
79f48da
Add GraphQLSchema types field
sogko May 31, 2016
1e33c35
[RFC] Add explicit context arg to graphql execution
sogko May 31, 2016
8c47143
Improve coercion error messages
sogko May 31, 2016
6e675a8
Test that `executor` threads `RootValue` correctly
sogko May 31, 2016
95bc032
Fix bug where @include directive is ignored if @skip is present.
sogko May 31, 2016
15268b7
Spec compliant @skip/@include.
sogko May 31, 2016
f5eed81
Add tests for type comparators
sogko May 31, 2016
c1dcff7
Clean up redundant code in `completeValueCatchingError`
sogko May 31, 2016
cec8092
Tests for `NewDirectives()` for better coverage
sogko May 31, 2016
a241e1c
RFC: Return type overlap validation
sogko May 31, 2016
34413d2
Merge branch 'cleaning' of https://github.com/kmulvey/graphql into so…
sogko May 31, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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