Hey there! How should I achieve the following: We ...
# orm-help
e
Hey there! How should I achieve the following: We have Users and an object X. There exists several Xs, and the User can have a collection with any number of Xs. How could I create the link between the X and the User? Should I have a "Connection" type that refers to a UserID and an X-Id? And how could I add to the collection with a mutation. Sorry if this is really dumb question, I've been reading the docs and googling but haven't found what I'm looking for 😕
Currently my datamodel looks like this:
Copy code
type User {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  name: String!
  weight: Int
  workouts: [Workout!]!
  exercises: [ExerciseUserConnection!]!
}

type Exercise {
  id: ID!
  name: String!
}

type ExerciseUserConnection {
  exerciseId: ID!
  userId: ID!
  maxReps: Int
}

type ExerciseWorkoutConnection {
  exerciseId: ID!
  workoutId: ID!
  sets: [Set!]!
}

type Set {
  reps: Int
}

type Workout {
  id: ID!
  date: String!
  createdAt: String!
  updatedAt: String!
  exercises: [ExerciseWorkoutConnection!]!
}
Is this the right approach? What are the best prectises for this kind of scenario and naming conventions?