You are building a simple apollo graphql server that exposes a single query getUser
and a mutation updateUser
as well as setting up a background service that on an interval of 1 minute updates a field from the user
object to a scheduled value for message
that is prefixed by automated -
Initially upon the server running make a single request to https://random-data-api.com/api/v2/users
to retrieve the user object and store the user details in memory database for later usage, note that we are not interested in all the data provided by the API end-point thus store only the properties that are needed by your user
object
// The user object
interface User {
id: number
uid: string
first_name: string
last_name: string
username: string
email: string
message: string
}
- You can use any packages to achieve the task as long as you comment your reasoning behind it
- The server you are building should be scalable and adheres with latest best practices
- The mutation
updateUser
should only accept astring
value, anything else should throw an error
- Use TypeScript to build the server application
- Set up a background service that runs every 1 min and updates the
user
object that is stored in memory propertymessage
to a value ofautomated - [DateNow]
- When calling the
getUser
query you should be able to retrieve the currentuser
details in memory - When calling the
updateUser
mutation you should be able to update themessage
property of the currentuser
details in memory with a value ofmanual - [Message]
were the[Message]
is whatever the value sent by the mutation - Implement error handling to gracefully handle any issues that may arise
- When calling the
getUser
query and requesting all the user object properties a response similar to the one below should be retrieved:{ "id": 3108, "uid": "c60f4629-14e8-4bcf-bfc8-00e92222ddb2", "first_name": "Chauncey", "last_name": "Mann", "username": "chauncey.mann", "email": "[email protected]", "message": "[some-message]" }
- When calling the
updateUser
mutation with a given message such thatmessage: "Hello world!"
the user object in the servers memory database should update themessage
property with a value ofmanual - Hello world!
- Whenever a minute passes your background service should update the
user
objectmessage
property with a value ofautomated - [DateNow]
where[DateNow]
is the current time in UTC format
- Code quality and maintainability
- Understanding of TypeScript, Node.js, Background services and Apollo GraphQL
- Integration skills with third-party APIs
- Error handling and unit testing
- Understanding of schedule-based tasks and implementation