Once you have added a remote service, you can access it via the GraphQL and REST APIs of Space Cloud.
Here’s how you can access a remote endpoint named adder of a service named arithmetic from your frontend:
query {
adder(
num1: 10,
num2: 20
) @arithmetic {
sum
}
}That’s it! The arguments sent by the client (num1 and num2 in this case) are available to the remote service in the request body as well as URL params. You can pass any number of arguments to the remote endpoint.
Let’s say you have added an endpoint hello in greeting service which accepts path parameters like these:
/hello/{args.name}Then you can query this service in the following manner:
query {
hello(
name: "John"
) @greeting {
sum
}
}The remote service gets name: John in the URL parameters as well as in the request body.