Skip to content

Commit

Permalink
Add failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
iamchanii committed Dec 28, 2024
1 parent be209e5 commit 8f9b8ee
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 178 deletions.
263 changes: 89 additions & 174 deletions e2e/grpc-example/__snapshots__/grpc-example.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`gRPC Example fetches movies by cast as a subscription correctly: 0 1`] = `
{
"data": {
"exampleSearchMoviesByCast": {
"cast": [
"Tom Cruise",
"Simon Pegg",
"Jeremy Renner",
],
"name": "Mission: Impossible Rogue Nation",
"rating": 0.9700000286102295,
"year": 0,
},
},
}
`;

exports[`gRPC Example fetches movies by cast as a subscription correctly: 1 1`] = `
{
"data": {
"exampleSearchMoviesByCast": {
"cast": [
"Tom Cruise",
"Simon Pegg",
"Henry Cavill",
],
"name": "Mission: Impossible - Fallout",
"rating": 0.9300000071525574,
"year": 0,
},
},
}
`;

exports[`gRPC Example generates the correct schema 1`] = `
"
schema
Expand Down Expand Up @@ -116,6 +82,7 @@ schema
enum join__Graph {
MOVIES @join__graph(name: "movies", url: "localhost:<movies_port>")
PETS @join__graph(name: "pets", url: "localhost:<pets_port>")
}
directive @grpcMethod(
Expand Down Expand Up @@ -143,19 +110,32 @@ The \`BigInt\` scalar type represents non-fractional signed whole numeric values
"""
scalar BigInt @join__type(graph: MOVIES)
scalar ObjMap @join__type(graph: MOVIES)
scalar ObjMap @join__type(graph: MOVIES) @join__type(graph: PETS)
scalar TransportOptions @join__type(graph: MOVIES)
scalar TransportOptions @join__type(graph: MOVIES) @join__type(graph: PETS)
scalar _DirectiveExtensions @join__type(graph: MOVIES)
scalar _DirectiveExtensions @join__type(graph: MOVIES) @join__type(graph: PETS)
"""
Request to get all pet stores
"""
scalar Empty_Input @join__type(graph: PETS) @specifiedBy(
url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf"
)
type Query @grpcRootJson(
subgraph: "movies"
name: "Root0"
rootJson: "{\\"options\\":{\\"syntax\\":\\"proto3\\"},\\"nested\\":{\\"EmptyRequest\\":{\\"fields\\":{},\\"comment\\":null},\\"MovieRequest\\":{\\"fields\\":{\\"movie\\":{\\"type\\":\\"Movie\\",\\"id\\":1,\\"comment\\":null}},\\"comment\\":null},\\"SearchByCastRequest\\":{\\"fields\\":{\\"castName\\":{\\"type\\":\\"string\\",\\"id\\":1,\\"comment\\":null}},\\"comment\\":null},\\"MoviesResult\\":{\\"fields\\":{\\"result\\":{\\"rule\\":\\"repeated\\",\\"type\\":\\"Movie\\",\\"id\\":1,\\"comment\\":\\"list of movies\\"}},\\"comment\\":\\"movie result message, contains list of movies\\"},\\"Example\\":{\\"methods\\":{\\"GetMovies\\":{\\"requestType\\":\\"MovieRequest\\",\\"responseType\\":\\"MoviesResult\\",\\"comment\\":\\"get all movies\\"},\\"SearchMoviesByCast\\":{\\"requestType\\":\\"SearchByCastRequest\\",\\"responseType\\":\\"Movie\\",\\"responseStream\\":true,\\"comment\\":\\"search movies by the name of the cast\\"}},\\"comment\\":null},\\"AnotherExample\\":{\\"methods\\":{\\"GetMovies\\":{\\"requestType\\":\\"MovieRequest\\",\\"responseType\\":\\"MoviesResult\\",\\"comment\\":\\"get all movies\\"},\\"SearchMoviesByCast\\":{\\"requestType\\":\\"SearchByCastRequest\\",\\"responseType\\":\\"Movie\\",\\"responseStream\\":true,\\"comment\\":\\"search movies by the name of the cast\\"}},\\"comment\\":null},\\"Genre\\":{\\"values\\":{\\"UNSPECIFIED\\":0,\\"ACTION\\":1,\\"DRAMA\\":2},\\"comment\\":null,\\"comments\\":{\\"UNSPECIFIED\\":null,\\"ACTION\\":null,\\"DRAMA\\":null}},\\"Movie\\":{\\"fields\\":{\\"name\\":{\\"type\\":\\"string\\",\\"id\\":1,\\"comment\\":null},\\"year\\":{\\"type\\":\\"int64\\",\\"id\\":2,\\"comment\\":null},\\"rating\\":{\\"type\\":\\"float\\",\\"id\\":3,\\"comment\\":null},\\"cast\\":{\\"rule\\":\\"repeated\\",\\"type\\":\\"string\\",\\"id\\":4,\\"comment\\":\\"list of cast\\"},\\"time\\":{\\"type\\":\\"google.protobuf.Timestamp\\",\\"id\\":5,\\"comment\\":null},\\"genre\\":{\\"type\\":\\"Genre\\",\\"id\\":6,\\"comment\\":null}},\\"comment\\":\\"movie message payload\\"},\\"google\\":{\\"nested\\":{\\"protobuf\\":{\\"nested\\":{\\"Timestamp\\":{\\"fields\\":{\\"seconds\\":{\\"type\\":\\"int64\\",\\"id\\":1},\\"nanos\\":{\\"type\\":\\"int32\\",\\"id\\":2}},\\"comment\\":null}}}}}}}"
) @extraSchemaDefinitionDirective(
directives: {transport: [{subgraph: "movies", kind: "grpc", location: "localhost:<movies_port>", options: {requestTimeout: 200000, metaData: {someKey: "someValue", connection_type: "{context.headers.connection}"}}}]}
) @join__type(graph: MOVIES) {
) @grpcRootJson(
subgraph: "pets"
name: "Root0"
rootJson: "{\\"options\\":{\\"syntax\\":\\"proto3\\"},\\"nested\\":{\\"Pet\\":{\\"fields\\":{\\"id\\":{\\"type\\":\\"int32\\",\\"id\\":1,\\"comment\\":null},\\"name\\":{\\"type\\":\\"string\\",\\"id\\":2,\\"comment\\":null}},\\"comment\\":\\"Message for pet store information\\"},\\"Empty\\":{\\"fields\\":{},\\"comment\\":\\"Request to get all pet stores\\"},\\"Pets\\":{\\"fields\\":{\\"pets\\":{\\"rule\\":\\"repeated\\",\\"type\\":\\"Pet\\",\\"id\\":1,\\"comment\\":null}},\\"comment\\":\\"Response with a list of pet stores\\"},\\"PetService\\":{\\"methods\\":{\\"GetAllPets\\":{\\"requestType\\":\\"Empty\\",\\"responseType\\":\\"Pets\\",\\"comment\\":null}},\\"comment\\":\\"Service definition for pet store\\"}}}"
) @extraSchemaDefinitionDirective(
directives: {transport: [{subgraph: "pets", kind: "grpc", location: "localhost:<pets_port>", options: {requestTimeout: 200000, metaData: {someKey: "someValue", connection_type: "{context.headers.connection}"}}}]}
) @join__type(graph: MOVIES) @join__type(graph: PETS) {
"""
get all movies
"""
Expand All @@ -165,7 +145,7 @@ type Query @grpcRootJson(
objPath: "Example"
methodName: "GetMovies"
responseStream: false
) @source(name: "Example_GetMovies", type: "MoviesResult", subgraph: "movies")
) @source(name: "Example_GetMovies", type: "MoviesResult", subgraph: "movies") @join__field(graph: MOVIES)
"""
search movies by the name of the cast
"""
Expand All @@ -175,12 +155,12 @@ type Query @grpcRootJson(
objPath: "Example"
methodName: "SearchMoviesByCast"
responseStream: true
) @source(name: "Example_SearchMoviesByCast", type: "[Movie]", subgraph: "movies")
) @source(name: "Example_SearchMoviesByCast", type: "[Movie]", subgraph: "movies") @join__field(graph: MOVIES)
exampleConnectivityState(tryToConnect: Boolean) : ConnectivityState @grpcConnectivityState(subgraph: "movies", rootJsonName: "Root0", objPath: "Example") @source(
name: "Example_connectivityState"
type: "ConnectivityState"
subgraph: "movies"
)
) @join__field(graph: MOVIES)
"""
get all movies
"""
Expand All @@ -190,7 +170,7 @@ type Query @grpcRootJson(
objPath: "AnotherExample"
methodName: "GetMovies"
responseStream: false
) @source(name: "AnotherExample_GetMovies", type: "MoviesResult", subgraph: "movies")
) @source(name: "AnotherExample_GetMovies", type: "MoviesResult", subgraph: "movies") @join__field(graph: MOVIES)
"""
search movies by the name of the cast
"""
Expand All @@ -204,12 +184,24 @@ type Query @grpcRootJson(
name: "AnotherExample_SearchMoviesByCast"
type: "[Movie]"
subgraph: "movies"
)
) @join__field(graph: MOVIES)
anotherExampleConnectivityState(tryToConnect: Boolean) : ConnectivityState @grpcConnectivityState(subgraph: "movies", rootJsonName: "Root0", objPath: "AnotherExample") @source(
name: "AnotherExample_connectivityState"
type: "ConnectivityState"
subgraph: "movies"
)
) @join__field(graph: MOVIES)
petServiceGetAllPets(input: Empty_Input) : Pets @grpcMethod(
subgraph: "pets"
rootJsonName: "Root0"
objPath: "PetService"
methodName: "GetAllPets"
responseStream: false
) @source(name: "PetService_GetAllPets", type: "Pets", subgraph: "pets") @join__field(graph: PETS)
petServiceConnectivityState(tryToConnect: Boolean) : ConnectivityState @grpcConnectivityState(subgraph: "pets", rootJsonName: "Root0", objPath: "PetService") @source(
name: "PetService_connectivityState"
type: "ConnectivityState"
subgraph: "pets"
) @join__field(graph: PETS)
}
"""
Expand Down Expand Up @@ -265,12 +257,27 @@ type Subscription @join__type(graph: MOVIES) {
) @source(name: "AnotherExample_SearchMoviesByCast", type: "Movie", subgraph: "movies")
}
enum ConnectivityState @join__type(graph: MOVIES) {
IDLE @join__enumValue(graph: MOVIES)
CONNECTING @join__enumValue(graph: MOVIES)
READY @join__enumValue(graph: MOVIES)
TRANSIENT_FAILURE @join__enumValue(graph: MOVIES)
SHUTDOWN @join__enumValue(graph: MOVIES)
"""
Response with a list of pet stores
"""
type Pets @join__type(graph: PETS) {
pets: [Pet]
}
"""
Message for pet store information
"""
type Pet @join__type(graph: PETS) {
id: Int
name: String
}
enum ConnectivityState @join__type(graph: MOVIES) @join__type(graph: PETS) {
IDLE @join__enumValue(graph: MOVIES) @join__enumValue(graph: PETS)
CONNECTING @join__enumValue(graph: MOVIES) @join__enumValue(graph: PETS)
READY @join__enumValue(graph: MOVIES) @join__enumValue(graph: PETS)
TRANSIENT_FAILURE @join__enumValue(graph: MOVIES) @join__enumValue(graph: PETS)
SHUTDOWN @join__enumValue(graph: MOVIES) @join__enumValue(graph: PETS)
}
enum Genre @join__type(graph: MOVIES) {
Expand Down Expand Up @@ -313,139 +320,47 @@ input SearchByCastRequest_Input @join__type(graph: MOVIES) {
exports[`gRPC Example gets movies correctly: get-movies-grpc-example-result 1`] = `
{
"data": {
"exampleGetMovies": {
"result": [
"exampleGetMovies": null,
},
"errors": [
{
"locations": [
{
"cast": [
"Leonardo DiCaprio",
"Jonah Hill",
"Margot Robbie",
],
"name": "The Wolf of Wall Street",
"rating": 0.7799999713897705,
"time": {
"seconds": 1608422400000,
},
"year": 0,
"column": 9,
"line": 3,
},
],
"message": "Unexpected error.",
"path": [
"exampleGetMovies",
],
},
},
],
}
`;

exports[`gRPC Example streams movies by cast correctly: 0 1`] = `
exports[`gRPC Example gets pets correctly: get-pets-grpc-example-result 1`] = `
{
"data": {
"exampleSearchMoviesByCast": [],
},
}
`;

exports[`gRPC Example streams movies by cast correctly: 1 1`] = `
{
"data": {
"exampleSearchMoviesByCast": [
{
"cast": [
"Tom Cruise",
"Simon Pegg",
"Jeremy Renner",
],
"name": "Mission: Impossible Rogue Nation",
"rating": 0.9700000286102295,
"year": 0,
},
],
},
}
`;

exports[`gRPC Example streams movies by cast correctly: 2 1`] = `
{
"data": {
"exampleSearchMoviesByCast": [
{
"cast": [
"Tom Cruise",
"Simon Pegg",
"Jeremy Renner",
],
"name": "Mission: Impossible Rogue Nation",
"rating": 0.9700000286102295,
"year": 0,
},
{
"cast": [
"Tom Cruise",
"Simon Pegg",
"Henry Cavill",
],
"name": "Mission: Impossible - Fallout",
"rating": 0.9300000071525574,
"year": 0,
},
],
},
}
`;

exports[`gRPC Example streams movies by cast correctly: 3 1`] = `
{
"data": {
"exampleSearchMoviesByCast": [
{
"cast": [
"Tom Cruise",
"Simon Pegg",
"Jeremy Renner",
],
"name": "Mission: Impossible Rogue Nation",
"rating": 0.9700000286102295,
"year": 0,
},
{
"cast": [
"Tom Cruise",
"Simon Pegg",
"Henry Cavill",
],
"name": "Mission: Impossible - Fallout",
"rating": 0.9300000071525574,
"year": 0,
},
null,
],
},
}
`;

exports[`gRPC Example streams movies by cast correctly: 4 1`] = `
{
"data": {
"exampleSearchMoviesByCast": [
{
"cast": [
"Tom Cruise",
"Simon Pegg",
"Jeremy Renner",
],
"name": "Mission: Impossible Rogue Nation",
"rating": 0.9700000286102295,
"year": 0,
},
{
"cast": [
"Tom Cruise",
"Simon Pegg",
"Henry Cavill",
],
"name": "Mission: Impossible - Fallout",
"rating": 0.9300000071525574,
"year": 0,
},
null,
],
"petServiceGetAllPets": {
"pets": [
{
"id": 1,
},
{
"id": 2,
},
{
"id": 3,
},
{
"id": 4,
},
{
"id": 5,
},
],
},
},
}
`;
Loading

0 comments on commit 8f9b8ee

Please sign in to comment.