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

Research data model #38

Open
omarathon opened this issue Oct 17, 2021 · 2 comments
Open

Research data model #38

omarathon opened this issue Oct 17, 2021 · 2 comments
Assignees
Labels
p:medium Medium priority.

Comments

@omarathon
Copy link
Member

Specifically, how to get users into Amplify (current idea is table User in Amplify with trigger in Congito which adds them to the table), how to get them to the front-end (via GraphQL)

@omarathon omarathon added the p:medium Medium priority. label Oct 17, 2021
@Edward-Upton
Copy link
Contributor

Edward-Upton commented Oct 17, 2021

The code here could be a solution to this problem.

type User 
  @model 
  @auth(rules: [{ allow: owner, ownerField: "id", queries: null }]) {
  id: ID!
  username: String!
  conversations: [ConvoLink] @connection(name: "UserLinks")
  messages: [Message] @connection(name: "UserMessages")
	createdAt: String
	updatedAt: String
}

Here's a step by step explanation of how this would work:

  1. User logs in, Cognito handles authentication with Warwick.
  2. Once logged in, the user is redirected to warwick.ai.
  3. On redirection, the client will send a GraphQL mutation to create a new User item. The User model ensures that the user is actually logged in and will check they have a valid session using @auth. The logged-in user will have their id stored as the id in the User item, therefore subsequent login will not duplicate the item, just update it.

@Edward-Upton
Copy link
Contributor

Edward-Upton commented Oct 24, 2021

After some more research, I think we are better of just having a lambda function that will add a row to our DB (model called something like UserProfile) that will trigger on the Cognito after authentication/confirmation. This lambda function should also check if the user profile already exists first to avoid creating duplicates or removing old rows.

The UserProfile should store anything that we want to use in the platform e.g.:

Attributes
Name
Username / Email
Credits / Coins
Position (member/exec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p:medium Medium priority.
Projects
None yet
Development

No branches or pull requests

2 participants