Open marktani opened 6 years ago
Comment by kbrandwijk Monday Jun 26, 2017 at 19:22 GMT
Idea: could this be done my being able to mark fields on a Type as 'computed'? Then they could be left out of the generated input object / mutation parameters, so the client cannot provide values for them, and then set them in the TRANSFORM_ARGUMENT
hook.
Comment by tomhut Tuesday Jun 27, 2017 at 15:48 GMT
Just adding my use case for consideration: I have two related Types, A Route and a Location. Routes consist of a name and an array of points. A location has a latitude and longitude.
When a Route is created, as part of the transform request step I would like a function to be called which would return it's input but with a location dictionary added. This would then result in a related Location node being automatically created before the next step is called.
Comment by sorenbs Saturday Jul 29, 2017 at 20:56 GMT
This could also be solved by https://github.com/graphcool/feature-requests/issues/280
Comment by danmkent Monday Aug 21, 2017 at 11:10 GMT
I think this feature could also solve a use case raised on the slack group (by user dtuite):
Imagine I have a mobile application like Medium which has an
Article
model. I’ve released v1 of the app which orders articles based on theircreatedAt
datetime. Now I want to release a new version, v2, which adds apublishedAt
field toArticle
and uses that to order posts in the UI.First I add the field to my schema and write a script to migrate my data so that all existing articles have their
publishedAt
value set to that of thecreatedAt
value. Now I can release v2 of my app which displays articles based onpublishedAt
.The problem is that users on v1 of the app are still creating new articles which don’t have a
publishedAt
value. I can’t force them to upgrade and I can’t migrate the data on it’s way into Graphcool with a serverless function because I can’t add new fields to an incoming payload. As far as I can see I’m basically stuck running my original data migration script over and over until all legacy users have migrated.Is there a better way?
As I understand it, implementing this feature would enable us to add such missing fields to the incoming payload before it is processed by the rest of the pipeline. Is that right?
Issue by dkh215 Monday Jun 26, 2017 at 16:11 GMT Originally opened as https://github.com/graphcool/prisma/issues/278
I have several required fields in a model that I won’t be able to populate until I fetch data from a 3rd party API which I’d like to do at the Transform Request step. Right now, I have to make these fields optional in the Model but I'd like for them to be required so I can tap into Schema Validation.