-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
161 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/Prices.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.smallrye.graphql.test.apps.federation.price.api; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Id; | ||
import org.eclipse.microprofile.graphql.Query; | ||
|
||
@GraphQLApi | ||
public class Prices { | ||
private static final List<ProductWithPrice> PRICES = asList( | ||
ProductWithPrice.product("1", 100), | ||
ProductWithPrice.product("2", 400)); | ||
|
||
@Query | ||
public ProductWithPrice product(@Id String id) { | ||
return PRICES.stream() | ||
.filter(productWithPrice -> productWithPrice.getId().equals(id)) | ||
.findFirst().orElseThrow(() -> new RuntimeException("product not find")); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/ProductWithPrice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.smallrye.graphql.test.apps.federation.price.api; | ||
|
||
import org.eclipse.microprofile.graphql.Id; | ||
|
||
import io.smallrye.graphql.api.federation.Extends; | ||
import io.smallrye.graphql.api.federation.Key; | ||
|
||
/** | ||
* In a real federated service, this would also be a {@code Price}, but we can't have the same type twice within one service. | ||
*/ | ||
@Key(fields = "id") | ||
@Extends | ||
public class ProductWithPrice { | ||
public static ProductWithPrice product(String id, int price) { | ||
ProductWithPrice product = new ProductWithPrice(); | ||
product.setId(id); | ||
product.setPrice(price); | ||
return product; | ||
} | ||
|
||
@Id | ||
private String id; | ||
private int price; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public int getPrice() { | ||
return price; | ||
} | ||
|
||
public void setPrice(int price) { | ||
this.price = price; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.smallrye.graphql.test.apps.federation.product.api; | ||
|
||
import org.eclipse.microprofile.graphql.Id; | ||
|
||
import io.smallrye.graphql.api.federation.Key; | ||
|
||
@Key(fields = "id") | ||
public class Product { | ||
static Product product(String id, String name) { | ||
Product product = new Product(); | ||
product.setId(id); | ||
product.setName(name); | ||
return product; | ||
} | ||
|
||
@Id | ||
private String id; | ||
private String name; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Products.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.smallrye.graphql.test.apps.federation.product.api; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Id; | ||
import org.eclipse.microprofile.graphql.Query; | ||
|
||
@GraphQLApi | ||
public class Products { | ||
private static final List<Product> PRODUCTS = asList( | ||
Product.product("1", "Armchair"), | ||
Product.product("2", "Table")); | ||
|
||
@Query | ||
public Product product(@Id String id) { | ||
return PRODUCTS.stream() | ||
.filter(product -> product.getId().equals(id)) | ||
.findFirst().orElseThrow(() -> new RuntimeException("product not find")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
deepList{ | ||
names | ||
} | ||
deepListFoo{ | ||
bar | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
server/tck/src/test/resources/tests/federation/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"data": { | ||
"deepList": [ | ||
[ | ||
[ | ||
{ | ||
"names": [ | ||
"Phillip" | ||
] | ||
} | ||
] | ||
] | ||
], | ||
"deepListFoo": [ | ||
[ | ||
[ | ||
{ | ||
"bar": "bar" | ||
} | ||
] | ||
] | ||
] | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
server/tck/src/test/resources/tests/federation/test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore=false | ||
priority=100 |