Skip to content
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

add test for single flight requests with graphql data source #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
48 changes: 48 additions & 0 deletions pkg/graphql/execution_engine_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,54 @@ func TestExecutionEngineV2_Execute(t *testing.T) {
},
))

t.Run("execute operation with graphql data source on multiple root nodes (single flight)", runWithoutError(
ExecutionEngineV2TestCase{
schema: func(t *testing.T) *Schema {
schema := `
type Query {
name: String!
code: String!
currency: String!
}
`
parsedSchema, err := NewSchemaFromString(schema)
require.NoError(t, err)
return parsedSchema
}(t),
operation: func(t *testing.T) Request {
return Request{
OperationName: "Country",
Query: "query Country { name code currency }",
Variables: nil,
}
},
dataSources: []plan.DataSourceConfiguration{
{
RootNodes: []plan.TypeField{
{TypeName: "Query", FieldNames: []string{"name", "code", "currency"}},
},
Factory: &graphql_datasource.Factory{
HTTPClient: testNetHttpClient(t, roundTripperTestCase{
expectedHost: "example.com",
expectedPath: "/",
expectedBody: `{"query":"{name code currency}"}`,
sendResponseBody: `{"data":{"name":"Germany","code":"DE","currency":"EUR"}}`,
sendStatusCode: 200,
}),
},
Custom: graphql_datasource.ConfigJson(graphql_datasource.Configuration{
Fetch: graphql_datasource.FetchConfiguration{
URL: "https://example.com/",
Method: "GET",
},
}),
},
},
fields: []plan.FieldConfiguration{},
expectedResponse: `{"data":{"name":"Germany","code":"DE","currency":"EUR"}}`,
},
))

t.Run("execute the correct operation when sending multiple queries", runWithoutError(
ExecutionEngineV2TestCase{
schema: starwarsSchema(t),
Expand Down