web-ridge / gqlgen-sqlboiler

This is a plugin for gqlgen to generate converts + filter queries and resolvers for sqlboiler
MIT License
74 stars 13 forks source link

Example for one-to-many (Invoice/Order) #46

Open frederikhors opened 3 years ago

frederikhors commented 3 years ago

Do we have an example of how to manage a one-to-many model?

Example: an invoice with multiple rows. When I create or update an invoice the rows are saved or modified or deleted at the same time.

RichardLindhout commented 3 years ago

I now always create the invoice directly in my UI and save the rows after that with the calls for that. However for some use cases it would be better to have a graphql call which does all of that at once.

For now only one-to-one relationships are possible if you change the schema.grapql the right resolvers will be created, we don't support one-to-many yet you would need to customize your resolver for this use case.

It really need to be simpler though to create custom resolvers without opting out of the generated resolver process, we would like to add this in the future.

frederikhors commented 3 years ago

I can use two calls too. But I need to do this calls in a DB transaction, so one call. I can change that, I know, but sometimes I can't.

RichardLindhout commented 3 years ago

You can do that if you create an extra mutation for that in your schema.graphql and an extra resolver to support that use case

Richard Lindhout | Eigenaar Bel mij +31 6 43 42 45 67 <+31643424567>

Beatrixlaan 2, 4694EG Scherpenisse

KVK 56845367 BTW NL002365659B60 IBAN NL93 BUNQ 2038 9661 33 WEB webRidge.nl https://webRidge.nl

Op vr 4 dec. 2020 om 20:25 schreef frederikhors notifications@github.com:

I can use two calls too. But I need to do this calls in a DB transaction, so one call. I can change that, I know, but sometimes I can't.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/web-ridge/gqlgen-sqlboiler/issues/46#issuecomment-738971797, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRRARKJZYCYNJ2XSOF56PTSTEZTJANCNFSM4UNGUUKA .