it loads them in the introspection playground but ...
# orm-help
a
it loads them in the introspection playground but not my api one. In my api I'm using
forwardTo
w
how your resolver looks like?
and app schema
a
@woss no resolver because just using forwardTo
schema looks like this:
course(where: CourseWhereUniqueInput!, userFirst: Int, userLast: Int): Course
w
you get
items:null
?
a
yea
w
i can think of 2 things, `1 no items are connected to the unit, or the nested feature has a bug. how does the items relation looks like in the unit type in datamodel
a
Copy code
type ContentPiece {
  id: ID! @unique
  creator: User!
  course: Course! @relation(name: "CourseContent")
  unit: [CourseUnit!]!
  name: String!
  description: String
  type: String!
  url: String!
  forUnits: Boolean!
  createdAt: DateTime!
  updatedAt: DateTime!
}
Copy code
type CourseUnit {
  id: ID! @unique
  course: Course!
  name: String!
  description: String!
  items: [ContentPiece!]!
  visible: Boolean @default(value: false)
  createdAt: DateTime!
  updatedAt: DateTime!
}
Copy code
type Course {
  id: ID! @unique
  userRoles: [CourseUser!]! @relation(name: "CourseMembers")
  name: String! @unique
  title: String
  description: String
  activations: [Activation!]!
  term: String
  units: [CourseUnit!]!
  files: [ContentPiece!]! @relation(name: "CourseContent")
  announcements: [MessageTarget!]! @relation(name: "MessageTargetCourse")
  createdAt: DateTime!
  updatedAt: DateTime!
}
I am able to get
items
back by running the same query on the introspection playground
w
but you are not getting it in the app?
a
right
w
interesting ...
a
and not getting it through my api playground
w
why not create the app schema and use graphqlgen to get the resolvers. i'm 100% sure that forwarding will cause you many issues. as well, wit this approach you are not decoupling the app and server.
units: [CourseUnit!]!
doesn't have the relation
consider keeping consisent names . like this :
a
which one does have the relation?
w
sec.
Copy code
type ContentPiece {
  id: ID! @unique
  creator: User!
  course: Course! @relation(name: "CourseContent")
  unit: [CourseUnit!]!
  name: String!
  description: String
  type: String!
  url: String!
  forUnits: Boolean!
  createdAt: DateTime!
  updatedAt: DateTime!
}
type ContentPiece {
  id: ID! @unique
  creator: User!
  course: Course! @relation(name: "ContentPieceToCourseContent")
  unit: [CourseUnit!]! @relation(name: "ContentPieceToCourseUnit")
  name: String!
  description: String
  type: String!
  url: String!
  forUnits: Boolean!
  createdAt: DateTime!
  updatedAt: DateTime!
}
type Course {
  id: ID! @unique
  userRoles: [CourseUser!]! @relation(name: "CourseToCourseMembers")
  name: String! @unique
  title: String
  description: String
  activations: [Activation!]! @relation(name: "CourseToActivation")
  term: String
  courseUnit: [CourseUnit!]! @relation(name: "CourseToCourseUnit")
  contentPieces: [ContentPiece!]! @relation(name: "CourseToContentPiece")
  announcements: [MessageTarget!]! @relation(name: "CourseToMessageTargetCourse")
  createdAt: DateTime!
  updatedAt: DateTime!
}
i'd write the model something like this.
a
ok thanks @woss!
what do people use graphql-binding for? am I not supposed to use it?
w
think of it as an SDK for an api. if you work with twitter then you can install twitter JS SDK, graphql-binding is SDK for graphql, it's more general, since graphql is always the same format
here is the real life example, it's more complex than eny other example out there. https://gitlab.com/sensio.photo/sensio-faas/tree/master/services/api
let me know if you have any other q
a
ok awesome thanks so much for your time!
🤘 2