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
const ProductOverview = () => { | |
const { id } = useParams(); | |
const { loading, data, error } = useProductAndReviewsQuery({ | |
variables: { | |
id | |
}, | |
}) |
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
query ProductAndReviews($id: ID!) { | |
product(id: $id) { | |
id | |
name | |
description, | |
reviews { | |
id, | |
text, | |
starRating | |
} |
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
overwrite: true | |
schema: "http://localhost:4000" | |
documents: "src/**/!(*.d).{ts,tsx,graphql}" | |
generates: | |
src/generated/graphql-types.ts: | |
plugins: | |
- "typescript" | |
- "typescript-operations" | |
- "typescript-react-apollo" | |
config: |
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
{ | |
"data": { | |
"product": { | |
"id": "1", | |
"name": "Saturn V", | |
"description": "The Original Super Heavy-Lift Rocket!", | |
"createdDate": "2022-08-27T13:01:54+03:00", | |
"reviews": [ | |
{ | |
"id": "1020", |
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
query Products { | |
product(id: 1) { | |
id | |
name | |
description, | |
createdDate, | |
reviews{ | |
id, | |
text, | |
starRating |
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
@Controller | |
class ReviewController( | |
private val reviewService: ReviewService | |
) { | |
@BatchMapping | |
fun reviews(products: MutableList<Product>): Mono<Map<Product, List<Review>>> { | |
val productIds = products.map {it.id}.toMutableList() | |
val result = reviewService.getReviewsByProductIdsIn(productIds) | |
return result |
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
type Product @key(fields: "id") @extends { | |
id: ID! @external | |
reviews: [Review!]! | |
} | |
type Review { | |
id: ID!, | |
text: String | |
starRating: Int! | |
} |
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
scalar OffsetDateTime | |
type Query { | |
product(id: ID!): Product | |
products: [Product!]! | |
} | |
type Product @key(fields: "id") { | |
id: ID! | |
name: String! |
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
const startGateway = (config, apolloGatewayConfig) => { | |
const corsOptions = { | |
origin: config.CORS_ALLOWED_ORIGINS.split(", "), | |
credentials: config.CORS_ALLOW_CREDENTIALS | |
} | |
const gateway = new ApolloGateway(apolloGatewayConfig); | |
const server = new ApolloServer({ | |
gateway, |
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
public class AcceptHeaderResolver extends AcceptHeaderLocaleResolver { | |
private static final String LOCALE_PARAM = "locale"; | |
@Override | |
public Locale resolveLocale(HttpServletRequest request) { | |
String localeParam = request.getParameter(LOCALE_PARAM); | |
if (StringUtils.hasText(localeParam)) { | |
Locale locale = StringUtils.parseLocaleString(localeParam); | |
this.setDefaultLocale(locale); |
NewerOlder