Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize user data and implement user retrieval by ID #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jose250698
Copy link

Description

This pull request addresses two main tasks in the resolver module:

  1. Normalizing user data: Previously, the resolver returned an empty array of users. This update implements the normalizeUser function to convert input user objects from different formats into a uniform schema. Properties from both userData1 and userData2 are mapped to this uniform schema.
  2. Implementing user retrieval by ID: The getUserById function is now implemented to return a user by their ID from the correct data source. It checks the type of the ID to determine whether to search in userData1 or userData2. userData1 contains UUIDs (strings), while userData2 contains numerical IDs.

Changes Made

  • Added implementation for normalizeUser function to convert input user objects into a uniform schema.
  • Modified getUsers function to utilize the normalizeUser function for each user object before returning the final array of normalized users.
  • Implemented getUserById function to return a user by their ID from the correct data source.
  • Updated tests in resolver.test.ts to ensure correct functionality of getUserById for both UUIDs and numerical IDs, as well as to verify that the correct data source is used based on the ID type.

These changes enhance the resolver module's functionality and ensure consistency in user data representation and retrieval.

@jose250698 jose250698 marked this pull request as ready for review May 9, 2024 04:05
jose250698 added 2 commits May 9, 2024 00:45
When querying the source field in Apollo GraphQL Playground, the error "Enum DataSource cannot represent value: 0" was returned, meaning that the default value of an enum is the index of enum value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant