kriasoft / react-firebase-starter

Boilerplate (seed) project for creating web apps with React.js, GraphQL.js and Relay
https://firebase.reactstarter.com
MIT License
4.51k stars 755 forks source link

Mutation example needed #262

Open yakneens opened 7 years ago

yakneens commented 7 years ago

This is a great boilerplate, but it bills itself as not only being for static sites but also for single-page-applications, thus it would be nice to see examples of full object CRUD. I would be very grateful if you could work the Create, Update, and Delete mutations on Story into this current framework.

DaveyEdwards commented 6 years ago

I know the relay mutations on the frontend side are not in this project yet, but if you are wondering about the backend mutations to go with this you can find them here

https://github.com/kriasoft/nodejs-api-starter/tree/master/src/schema

yakneens commented 6 years ago

Thanks, I appreciate the link. The back-end honestly is just so much more straightforward and testable. The front-end is, however, pure black magic, to the point where I'm starting to doubt whether Relay is a good framework to move forward with. Support on the FB side seems nonexistent which is a real shame. Thanks again for your help though.

DaveyEdwards commented 6 years ago

Relay mutations on the frontend are actually alot easier then most think once you get one working. After that it is mostly copy paste and change a few fields. Ill post a link to my static-boilerplate here when I finish hooking up my frontend.

If you want to see my old project with relay mutations here was a base project I had working (based on react-starter-kit) https://github.com/DaveyEdwards/myiworlds/tree/master/src/routes/createCircle (I was trying many things in there so the project is quite messy). Is there something in particular that confuses you about relay?

If your building something that you wish to be very performant for global scale Id recommend keeping with it until something blows it out of the water :)

yakneens commented 6 years ago

Thanks @DaveyEdwards, I appreciate your offer of help, and the link to your repo. My plight is documented in this issue - https://github.com/facebook/relay/issues/2178, and my actual repo that is based on react-static-boilerplate is here - https://github.com/llevar/react-test2/tree/master/src/Home, it basically has to do with updating the store after the mutation succeeds on the server.

I also am not sure I really understand how one is meant to implement a page that features a list of objects that don't really have a parent in the object model. All of the Relay examples I have seen that feature a list are implementing a one-to-many relationship using a Connection, but my use case has a list that is top-level. I'm still implementing it using a Connection which maybe isn't right, but I'm not sure how one is supposed to do it otherwise. I honestly think this is a basic enough use case that there should be more than one working example out there already - a page with a table, where you can do CRUD on its rows and it dynamically updates. But so far no dice.

I'd be much obliged if you have any ideas...

DaveyEdwards commented 6 years ago

I tried to look through your problem, but am unable to offer any advice. I havn't touched relay mutations in a little while so its not fresh in my mind. It looks like your doing things right, except I have never done anything with the connection like client:root:allWorkflows{"first":50}".
I would recommend to post your question on stack overflow for best change at getting help, and then just search github for projects using the specific problem your having. example "ConnectionHandler.getConnection" and search by javascript (looking how others have done it and comparing it to my own has been my best resource with relay/graphql)

Filson14 commented 6 years ago

Hi @llevar , have You resolved Your problem with list update after mutation? I deal with similar use case and wonder if You can provide any clue :wink:

rdhanaraj commented 5 years ago

Having the same blocker here in 2019. Will see if I can get something to work.

koistya commented 5 years ago

You may find some examples here: