I have a question: Using Apollo Server I'm able to...
# prisma-whats-new
r
I have a question: Using Apollo Server I'm able to insert a value in the db and then 'override' it in the type resolvers like in the following code. Basically here I store an Int value in the db that is actually a String in the schema
Copy code
type Example {
  _id: String!
  description: String
  length: String
}

type Query {
 listExamples: [Example]
}

type Mutation {
  insertExample(description: String): Example
}

schema {
  query: Query
  mutation: Mutation
}

//In my resolvers
Mutation: {
  insertExample(_, {description}): {
    const exampleId = Examples.insert({
      description: description,
      length: description.length
    })
    return Examples.findOne(exampleId)
  }
},
Query; {
 listExample(_){
   Examples.find({}).fetch()
 }
},
Example({length}) {
  const info = length > 25 ? 'LONG' : 'SHORT'
  return info
}
Is this possible in graphcool?
n
@ric0 Hey, we are already working on so called computed fields for exactly this use case: https://github.com/graphcool/feature-requests/issues/56 For now you would compute the description length and add it as another int field called
lenght
client side
r
Thank you for your answer. So if I understood well I have to compute it in client side code and cannot do anything server side, right?
👍 1
Also if there is any ETA for computed fields 🙂
n
Currently there is none
r
Ok. Thanks 🙂
n
You're welcome! Thanks for your feedback, this helps us to make sure we include all the use cases when building the computed fields feature simple smile