Foreign Environments
danger
Foreign parsers is a sub-system of Dynamic Resolvers, which are still in research/experimental stages.
Foreign Pathom is the ability of Pathom 3 to make automatic integration between different Pathom environments.
This mechanism provides a simple way to connect resolvers that may run in completely different contexts (different machines or processes).
Foreign setup
To demonstrate it working, let's start with some resolvers to list some TODO ids and another resolver to pull the TODO details.
Now we are going to start a new Pathom environment, connect and extend the previous one. The local extension will add the ability to know if a TODO item was cancelled. You can imagine this is a separate service responsible for the cancellation part of this hypothetical system.
note
Using the boundary interface ensures the request handler fulfills the expected contract when calling a remote Pathom instance.
How it works
When we use (pcf/foreign-register foreign-request)
, it makes a request that asks
for the indexes available in that instance.
You can try it yourself by requesting the query:
Pathom them transform the indexes in dynamic resolvers and
we add these new indexes using pci/register
.
Check the dynamic resolvers documentation for more details about this process.
Foreign HTTP Example
It's important to note that the foreign environment might well be in a different machine. The integration process is serializable, and can work over the network.
I have this same example deployed at https://southamerica-east1-pathomdemos.cloudfunctions.net/development-pathom-server-demo
Here is how we can do this integration using this HTTP based communication: