Hi @tinrab ,
First at all, thanks for your articles at outcrawl.com, I am personally learning a lot from them.
However I have a couple of doubts:
- Why do you take Order model out from the code generation tool? You mention that " more control is needed for the Order mode" but I don't understand why.
- I am not able to retrieve any Order when querying Accounts, it always returns an empty array. I have already checked that all data from creation of Accounts, Products and Orders is in the database. Also, I have noticed that method Account_orders is never called.
I have read the docs from https://gqlgen.com/getting-started/ where the binding rules are described:
- If there is a property with that name and type, use it
- If there is a method with that name and type, use it
- Otherwise, add it to the Resolvers interface. This is the magic.
So I am assuming that since model Account contains a property []Order it tries to resolve it without calling to Account_orders, resulting always in an empty array. Also I am totally confused on the example provided in gqlgen tutorial: both User and Todo are not pregenerated (but User would generate the same model, while Todo uses a String instead of an Object for property UserID), and the Todo_user method is added automatically to the Resolvers interface, something that is not happening in the Spidey example.
There is something that I'm missing...
Thanks!
Hi @tinrab ,
First at all, thanks for your articles at outcrawl.com, I am personally learning a lot from them.
However I have a couple of doubts:
I have read the docs from https://gqlgen.com/getting-started/ where the binding rules are described:
So I am assuming that since model Account contains a property []Order it tries to resolve it without calling to Account_orders, resulting always in an empty array. Also I am totally confused on the example provided in gqlgen tutorial: both User and Todo are not pregenerated (but User would generate the same model, while Todo uses a String instead of an Object for property UserID), and the Todo_user method is added automatically to the Resolvers interface, something that is not happening in the Spidey example.
There is something that I'm missing...
Thanks!