Thursday, October 24, 2019

In an Angular application that interacts with GraphQL instead of ReST you may only need one method to crosstalk to the server.

Everything is a POST and while you may hand in queries of different shapes, all of the queries are basically strings. You basically need something like the first method here only it would take a string (the graph) as the one inbound parameter at the method signature and hand back an Observable of any instead of an Observable of Campaign by replacing...

.map((res: Response) => <Campaign>res.json());

 
 

...with just a semicolon. The many other actors which use this method can then use the syntax above to map the Observable of any to an Observable of Campaign or what the circumstance demands, be it what it may, case-to-case, instead.

No comments:

Post a Comment