Skip to content

Commit

Permalink
Updated graphql.Graphql() to use the latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
sogko committed Nov 5, 2015
1 parent fb0f76e commit f5cf06c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 48 deletions.
2 changes: 1 addition & 1 deletion connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestConnectionDefinition_IncludesConnectionAndEdgeFields(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: connectionTestSchema,
RequestString: query,
})
Expand Down
17 changes: 5 additions & 12 deletions examples/starwars/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import (
"testing"
)

func testGraphql(t *testing.T, p graphql.Params) *graphql.Result {
resultChannel := make(chan *graphql.Result)
go graphql.Graphql(p, resultChannel)
result := <-resultChannel
return result
}

func TestConnection_TestFetching_CorrectlyFetchesTheFirstShipOfTheRebels(t *testing.T) {
query := `
query RebelsShipsQuery {
Expand Down Expand Up @@ -46,7 +39,7 @@ func TestConnection_TestFetching_CorrectlyFetchesTheFirstShipOfTheRebels(t *test
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand Down Expand Up @@ -93,7 +86,7 @@ func TestConnection_TestFetching_CorrectlyFetchesTheFirstTwoShipsOfTheRebelsWith
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand Down Expand Up @@ -146,7 +139,7 @@ func TestConnection_TestFetching_CorrectlyFetchesTheNextThreeShipsOfTheRebelsWit
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand Down Expand Up @@ -180,7 +173,7 @@ func TestConnection_TestFetching_CorrectlyFetchesNoShipsOfTheRebelsAtTheEndOfThe
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand Down Expand Up @@ -262,7 +255,7 @@ func TestConnection_TestFetching_CorrectlyIdentifiesTheEndOfTheList(t *testing.T
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/starwars/mutation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestMutation_CorrectlyMutatesTheDataSet(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
VariableValues: params,
Expand Down
10 changes: 5 additions & 5 deletions examples/starwars/object_identification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestObjectIdentification_TestFetching_CorrectlyFetchesTheIDAndTheNameOfTheR
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand All @@ -52,7 +52,7 @@ func TestObjectIdentification_TestFetching_CorrectlyRefetchesTheRebels(t *testin
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand All @@ -77,7 +77,7 @@ func TestObjectIdentification_TestFetching_CorrectlyFetchesTheIDAndTheNameOfTheE
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand All @@ -104,7 +104,7 @@ func TestObjectIdentification_TestFetching_CorrectlyRefetchesTheEmpire(t *testin
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand All @@ -131,7 +131,7 @@ func TestObjectIdentification_TestFetching_CorrectlyRefetchesTheXWing(t *testing
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: starwars.Schema,
RequestString: query,
})
Expand Down
12 changes: 6 additions & 6 deletions mutation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestMutation_WithClientMutationId_BehavesCorrectly_RequiresAnArgument(t *te
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: mutationTestSchema,
RequestString: query,
})
Expand All @@ -104,7 +104,7 @@ func TestMutation_WithClientMutationId_BehavesCorrectly_ReturnsTheSameClientMuta
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: mutationTestSchema,
RequestString: query,
})
Expand All @@ -131,7 +131,7 @@ func TestMutation_WithClientMutationId_BehavesCorrectly_SupportsPromiseMutations
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: mutationTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestMutation_IntrospectsCorrectly_ContainsCorrectInput(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: mutationTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestMutation_IntrospectsCorrectly_ContainsCorrectPayload(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: mutationTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestMutation_IntrospectsCorrectly_ContainsCorrectField(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: mutationTestSchema,
RequestString: query,
})
Expand Down
4 changes: 2 additions & 2 deletions node_global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestGlobalIDFields_GivesDifferentIDs(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: globalIDTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestGlobalIDFields_RefetchesTheIDs(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: globalIDTestSchema,
RequestString: query,
})
Expand Down
27 changes: 10 additions & 17 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ func init() {
Query: nodeTestQueryType,
})
}

func testGraphql(t *testing.T, p graphql.Params) *graphql.Result {
resultChannel := make(chan *graphql.Result)
go graphql.Graphql(p, resultChannel)
result := <-resultChannel
return result
}
func TestNodeInterfaceAndFields_AllowsRefetching_GetsTheCorrectIDForUsers(t *testing.T) {
query := `{
node(id: "1") {
Expand All @@ -113,7 +106,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_GetsTheCorrectIDForUsers(t *tes
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand All @@ -134,7 +127,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_GetsTheCorrectIDForPhotos(t *te
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand All @@ -159,7 +152,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_GetsTheCorrectNameForUsers(t *t
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand All @@ -184,7 +177,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_GetsTheCorrectWidthForPhotos(t
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand All @@ -207,7 +200,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_GetsTheCorrectTypeNameForUsers(
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand All @@ -230,7 +223,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_GetsTheCorrectTypeNameForPhotos
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand All @@ -254,7 +247,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_IgnoresPhotoFragmentsOnUser(t *
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand All @@ -273,7 +266,7 @@ func TestNodeInterfaceAndFields_AllowsRefetching_ReturnsNullForBadIDs(t *testing
"node": nil,
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -318,7 +311,7 @@ func TestNodeInterfaceAndFields_CorrectlyIntrospects_HasCorrectNodeInterface(t *
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -379,7 +372,7 @@ func TestNodeInterfaceAndFields_CorrectlyIntrospects_HasCorrectNodeRootField(t *
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: nodeTestSchema,
RequestString: query,
})
Expand Down
8 changes: 4 additions & 4 deletions plural_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestPluralIdentifyingRootField_AllowsFetching(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: pluralTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestPluralIdentifyingRootField_CorrectlyIntrospects(t *testing.T) {
},
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: pluralTestSchema,
RequestString: query,
})
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestPluralIdentifyingRootField_Configuration_ResolveSingleInputIsNil(t *tes
"usernames": nil,
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: pluralTestSchema,
RequestString: query,
})
Expand All @@ -206,7 +206,7 @@ func TestPluralIdentifyingRootField_Configuration_ArgNames_WrongArgNameSpecified
"usernames": nil,
},
}
result := testGraphql(t, graphql.Params{
result := graphql.Graphql(graphql.Params{
Schema: pluralTestSchema,
RequestString: query,
})
Expand Down

0 comments on commit f5cf06c

Please sign in to comment.