https://www.prisma.io/ logo
Join Slack
Powered by
# prisma-whats-new
  • c

    cartogram

    01/19/2017, 6:14 PM
    I'm just getting the hang of graph.cool and apollo coming from reindex and relay, where if a model implemented a Node interface there was more ceremony around the mutations. Seems like that might not be the case here
  • n

    nilan

    01/19/2017, 6:14 PM
    Can you elaborate with what you mean by ceremony?
  • c

    cartogram

    01/19/2017, 6:29 PM
    Well, how would you design the schema for a survey where you have a Survey model and an Answers model?
  • c

    cartogram

    01/19/2017, 6:30 PM
    and the survey has questions, and each question has a
    label
    and
    hint
    , for example...
  • n

    nilan

    01/19/2017, 6:30 PM
    so a Survey probably also has many questions, right? so that's the first part. One Survey is related to Many Questions
  • n

    nilan

    01/19/2017, 6:30 PM
    right
  • c

    cartogram

    01/19/2017, 6:30 PM
    SO Questions is a model with hint and label
  • c

    cartogram

    01/19/2017, 6:31 PM
    and has a many to many relation to Survey
  • n

    nilan

    01/19/2017, 6:31 PM
    so a question can appear in different surveys
  • c

    cartogram

    01/19/2017, 6:31 PM
    sorry, one to many
  • n

    nilan

    01/19/2017, 6:31 PM
    so only in one?
  • c

    cartogram

    01/19/2017, 6:33 PM
    only in one yeah, each survey questions are unique
  • c

    cartogram

    01/19/2017, 6:33 PM
    but conform to a shape
  • n

    nilan

    01/19/2017, 6:34 PM
    Copy code
    type Question {
      hint: String!
      label: String!
      survey: Survey
      answers: [Answer]
    }
    
    type Survey {
      title: String!
      questions: [Question]
    }
    
    type Answer {
      text: String!
      question: Question
      user: User
    }
    
    type User {
      answers: [Answer]
    }
  • n

    nilan

    01/19/2017, 6:34 PM
    that's probably it
  • n

    nilan

    01/19/2017, 6:36 PM
    a drawing of your data model can also help a lot. Depending on your needs, you might choose to directly relate a
    survey
    to its
    answers
    for example, then you would have to adjust accordingly
  • c

    cartogram

    01/19/2017, 6:38 PM
    Yeah, I think I was getting confused because I did not realize you could create a Survey and the Questions in one mutation
  • n

    nilan

    01/19/2017, 6:39 PM
    ah right. it's API sugar that we came up with. we call it nested mutations 🙂
  • n

    nilan

    01/19/2017, 6:39 PM
    you could split the task up into several mutations anyway
  • c

    cartogram

    01/19/2017, 6:40 PM
    Yeah, thats what I mean by ceremony in my message above. Creating all the Questions, then using the
    addtoQuestions
    type of mapping.
  • n

    nilan

    01/19/2017, 6:40 PM
    right
  • n

    nilan

    01/19/2017, 6:40 PM
    ok so I'm confused how this all has anything to do with
    JSON
    🙂
  • c

    cartogram

    01/19/2017, 6:42 PM
    I see now that JSON was not what I wanted, I just didn't fully understand the generated mutations that are built in to graph.cool
  • n

    nilan

    01/19/2017, 6:44 PM
    I think a great thing to do is just play around in the playground, as you already did. GraphiQL makes it fun to explore APIs 🙂
  • n

    nilan

    01/19/2017, 6:45 PM
    I want to push the documentation further but it's difficult to capture the flexibility of our API in static docs... That's why I'm excited about the integrated GraphiQLs. Have you seen them?
  • c

    cartogram

    01/19/2017, 6:45 PM
    Yeah I have, GraphiQL is the best
  • n

    nilan

    01/19/2017, 6:45 PM
    👍 it is
  • c

    cartogram

    01/19/2017, 6:46 PM
    yeah so just to clarify all of this, you guys have models that are similar to the List of Type: Question that I was used to with reindex. You basically define all your data shapes as models, even if you do not plan on using the create/delete/update mutations that are generated directly and only really plan on doing your mutation on the Parent nodes.
  • c

    cartogram

    01/19/2017, 6:47 PM
    So I will never create a Question directly, but I will create a Survey, which will create the questions
  • n

    nilan

    01/19/2017, 6:47 PM
    Interesting to see this differences in APIs. How do you relate a question with an answer if you define them with JSON?
1...808182...637Latest