Converting the app’s existing REST API calls to GraphQL API calls was the first step. By switching to GraphQL, the client application only needs to know how to make a GraphQL call and requests only the data it needs; it doesn’t have to know where the data comes from. Standardizing on GraphQL for this application would allow the company to add new data sources and switch data sources without impacting the application; the GraphQL queries would remain the same.
However, typically this would mean writing a GraphQL server and a lot of resolver code to map the APIs to the data. The less code to write and maintain, the better. As a declarative, configuration-driven hosted GraphQL server, StepZen made it easy to configure resolvers, eliminating the need for much of the code.
Nemanja Niciforovic, MD and Engineering Lead at Work & Co, explains: “With the GraphQL API on Mavenlink we are able to build out an internal app in weeks that lets us visualize and plan our resource management quickly, accurately and easily. Performance of this app is critical since it pulls together many bits of information. StepZen’s auto parallelism helped a lot. It also helps us future proof and scale as we add back-end services and build new apps on the single GraphQL API.”
Mavenlink has a comprehensive REST API to manage access to a wide variety of HR and resource management data. Using StepZen’s GraphQL directive—@rest—Work & Co was able to fine-tune the data available for the employee directory app. As a simple example, the team easily renamed fields in the Mavenlink API to match the names used in their application, eliminating cognitive load for the front-end developer and reducing the number of code changes required in the application.
Furthermore, the team was able to simplify the Mavenlink API through the use of StepZen’s @materializer directive. This enabled them to define types that include data from multiple API calls. For example, they added a “projects” type to the “user” type, which allowed the application developer to retrieve a user’s active projects at the same time as retrieving user details like profile photo and email address.
Pagination: The Mavenlink API limits the number of records returned by any single call, enforcing pagination. The Work & Co app was not built to support handling data this way, and reworking it to make use of pagination was not an effort they wanted to undertake. Using StepZen’s @sequence directive, the team was able to parallelize many REST API calls to the Mavenlink API and retrieve all pages of a result set with a single GraphQL query request.
Performance tuning: An unexpected benefit of this approach is performance tuning. Retrieving smaller page sizes with the REST API results in faster response times. So 10 parallel requests for 200 records each takes longer than 20 parallel requests for 100 records each. By defining the StepZen queries appropriately, the Work & Co application developer was able to fine-tune the performance of their GraphQL queries.
Security and caching: On top of all these specific implementation details, Work & Co benefited from StepZen’s overall approach to security and caching. Flexible security configurations allowed them to define queries that use an application-wide security context as well as ones that use user-specific security context. Such fine-grained control is very difficult to manage when using a REST API directly; it’s typically one or the other. StepZen’s automatic caching means that users of their application see improved performance with zero development effort.