This doc set is for users of the Gloo Mesh Gateway product to set up an Istio ingress gateway. For users of the Gloo Gateway product to set up an ingress gateway with the Kubernetes Gateway API instead, see the Gloo Gateway docs.
Schema merging
Consolidate the schema definitions and resolvers from multiple subschema instances into a single, stitched schema.
In Gloo Mesh Gateway, you can surface multiple APIs into one unified service by creating a Gloo GraphQLStitchedSchema custom resource. Gloo Mesh Gateway uses this resource to generate a stitched schema, which incorporates all the types and fields from each subschema. When clients query the route for the stitched schema, Gloo Mesh Gateway creates requests to the individual services, and then stitches the responses back together into one response to the client. For more information, see What is GraphQL stitching?.
For each API, define schema and select resolver services in your Gloo environment. Then, you can merge the GraphQL APIs together in a GraphQLStitchedSchema, and set up routing to this merged resolver.
For each subschema, use the following guides to create individual CRs for each API that define its schema and resolvers.
Define subschema in separate ApiDoc CRs. For the Bookinfo example, you might define three CRs for the product, reviews, and ratings services.
Choose how GraphQL requests are executed, and follow the guides to either proxy requests to existing GraphQL backends or define REST, gRPC, or mock resolvers for each schema.
Create one GraphQLStitchedSchema CR that references each GraphQL subschema. This example stitched schema for Bookinfo merges the GraphQL schema for each of the three APIs:
Create a route table that routes to a graphql.stitchedSchema destination. Specify your stitched schema resource name in the graphql.stitchedSchema.name field, such as stitched-graphql-schema in the following examples.
To route requests from clients that are external to your Gloo Mesh Gateway setup, you can use the following example route table.
To route requests from clients that are internal to your setup, such as if you use Gloo Mesh Enterprise, you can use the following example route table. Note that because the GraphQL destination references the stitched schema resource instead of a service, the value of hosts is arbitrary, as long as the request from the client app matches the host.
Send a request with a query to the GraphQL endpoint to verify that the request is successfully resolved by the gateway. This example command sends the request to the /graphql path and includes a query for the Bookinfo example.
To test routing to the server, choose one of the following options:
Log in to your client app and send a query to the host and path to verify that the GraphQL server is reachable through the route. For the example route table, you might use this curl command:
Create a temporary curl pod in the bookinfo namespace and send a request to the GraphQL server from your local machine.
Create the curl pod.
kubectl run -it -n bookinfo curl --image=curlimages/curl:7.73.0 --rm -- sh
Send a request with a query to the GraphQL endpoint to verify that the request is successfully resolved by the gateway. This example command sends the request to the /graphql path and includes a query for the Bookinfo example.