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

Feature: design graphql user schema #90

Merged
merged 3 commits into from
Jan 28, 2022

Conversation

tuanthanh2067
Copy link
Owner

@tuanthanh2067 tuanthanh2067 commented Jan 27, 2022

Related issue

Fixes #36

Type of Change

  • Feat: Change which adds functionality/new feature
  • Fix: Change which fixes an issue
  • Refactor: Change which improves the structure of the code
  • Docs: Change which improves documentation

Note

I bring the note up here because we have something to discuss here! For the fields, they can be nullable and non-nullable. For example: String! and [String!]! are non-nullable. [String!]! will always have to return an empty array or array of strings. I'm not sure about which fields should be nullable and which ones should be non-nullable.

For reference here

Description

This PR is to add user schema in GraphQL and add missing type in database as well. I also added a query to get user by email so we can test it out using our local database.

Screenshot

image

@vercel
Copy link

vercel bot commented Jan 27, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tuanthanh2067/seeksi/7dYhZLzv13yihHoSFfNAdPKqmUFM
✅ Preview: https://seeksi-git-feature-36-design-graphql-user-schema-tuanthanh2067.vercel.app

@tuanthanh2067
Copy link
Owner Author

There's 4 new types I just added, can you guys please check to see if I need to change anything to nullable or non-nullabel @oliver-pham @minhhang107

@oliver-pham
Copy link
Collaborator

I can't anticipate any problem with allowing all the fields in Image, Location, and Preference to be nullable. But, I think we're good with this for now.

@tuanthanh2067 tuanthanh2067 changed the title Feature/36 design graphql user schema Feature: design graphql user schema Jan 27, 2022
@tuanthanh2067
Copy link
Owner Author

tuanthanh2067 commented Jan 27, 2022

How about User type? @oliver-pham

@oliver-pham
Copy link
Collaborator

How about User type? @oliver-pham

Apart from the change in the resolver's response, I think it's good to be merged, @tuanthanh2067.

Comment on lines +9 to +10
dob: String!
sex: String!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create scalar types for dob and sex (e.g. Date and Sex). I'm not sure if we have time for this, but just writing it down for future enhancement.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, go head. For now, we can just use string.

@@ -1,6 +1,6 @@
const queries = {
userByEmail: async (_, args, { dataSources }) => {
return await dataSources.userAPI.findUser(args.email);
return await dataSources.userAPI.findUserByEmail(args.email);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to change the response in this resolver.

A response should have these fields:

  • code (status code of the response like 200, 404),
  • success: true/false
  • message (optional): the response error message if it fails
  • any data (e.g. user)

@tuanthanh2067 tuanthanh2067 merged commit c6eb305 into main Jan 28, 2022
@tuanthanh2067 tuanthanh2067 deleted the feature/36-design-graphql-user-schema branch January 28, 2022 03:10
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.

Design a GraphQL schema for a user
2 participants