Closed sjhitchner closed 3 years ago
This should not happen.
What is the name of the root model, foreign key and the model itself?
Ideally we would have a very small reproduction of the same case.
Thanks for your quick response!
Here is a link to a diagram of my schema. I guess
the root model would be named Recipe
.
https://github.com/sjhitchner/soapcalc/blob/sqlboiler/soap.png
Made a little progress this evening. Although I'm still getting some nil pointer panics and errors when I run convert_plugin.go
Reread the README and it triggered a thought. I had a self-referential foreign key. I have removed that and that seems to have solved one issue.
When using sqlboiler-graphql-schema
I needed to change the below line to relationType := boilerField.RelationshipName
otherwise I get a nil pointer panic. Not sure this is the correct change, but the tool no longer panics.
https://github.com/web-ridge/sqlboiler-graphql-schema/blob/main/main.go#L714
The schema that is generated is mostly right, but there are some manually changes I need to make for gqlgen
to work.
type Lye {
id: ID!
kind: String!
name: String!
note: String!
deletedAt: Int
updatedAt: Int!
createdAt: Int!
recipeBatchLye: RecipeBatchLye
lyeInventories: [LyeInventories] <=== Should not be type name not pluralized
}
type LyeInventory {
id: ID!
purchaseDate: Int!
expiryDate: Int!
cost: Float!
weight: Float!
concentration: Float!
lye: Lye!
supplier: Supplier!
deletedAt: Int
createdAt: Int!
updatedAt: Int!
}
...
input RecipeBatchWhere {
id: IDFilter
tag: StringFilter
productionDate: IntFilter
sellableDate: IntFilter
note: StringFilter
lipidWeight: FloatFilter
productionWeight: FloatFilter
curedWeight: FloatFilter
recipe: RecipeWhere
deletedAt: IntFilter
updatedAt: IntFilter
createdAt: IntFilter
batchRecipeBatchAdditives: BatchRecipeBatchAdditivesWhere <===== Prefixed with Batch should be RecipeBatchAdditiveWhere and not plural
batchRecipeBatchFragrances: BatchRecipeBatchFragrancesWhere
batchRecipeBatchLipids: BatchRecipeBatchLipidsWhere
batchRecipeBatchLyes: BatchRecipeBatchLyesWhere
batchRecipeBatchNotes: BatchRecipeBatchNotesWhere
or: RecipeBatchWhere
and: RecipeBatchWhere
}
After the above changes I was able to run convert_plugin.go
. It generated a number of helper files but also the below errors.
Still needed to wrap a nil check around this line. https://github.com/web-ridge/gqlgen-sqlboiler/blob/main/convert.go#L863
% go run convert_plugin.go
[convert] get boiler models
[convert] get extra's from schema
[convert] get model with information
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Fragrance.Inventory
[WARN] boiler type not available for AdditiveInventory
[WARN] boiler name not available for Supplier.AdditiveInventory
[WARN] boiler type not available for FragranceInventory
[WARN] boiler name not available for Supplier.FragranceInventory
[WARN] boiler type not available for LipidInventory
[WARN] boiler name not available for Supplier.LipidInventory
[WARN] boiler type not available for LyeInventory
[WARN] boiler name not available for Supplier.LyeInventory
[WARN] boiler name not available for RecipeBatch.Additives
[WARN] boiler name not available for RecipeBatch.Fragrances
[WARN] boiler name not available for RecipeBatch.Lipids
[WARN] boiler type not available for Lye
[WARN] boiler name not available for RecipeBatch.Lye
[WARN] boiler name not available for RecipeBatch.Notes
[WARN] boiler type not available for AdditiveInventory
[WARN] boiler type not available for FragranceInventory
[WARN] boiler type not available for AdditiveInventory
[WARN] boiler type not available for FragranceInventory
[WARN] boiler type not available for LipidInventory
[WARN] boiler type not available for LyeInventory
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Additive.Inventory
[WARN] boiler type not available for LipidInventory
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Lipid.Inventory
[WARN] boiler name not available for Recipe.Additives
[WARN] boiler name not available for Recipe.Batches
[WARN] boiler name not available for Recipe.Fragrances
[WARN] boiler name not available for Recipe.Lipids
[WARN] boiler name not available for Recipe.Steps
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Lye.Inventory
[WARN] boiler type not available for LyeInventory
[convert] render preload.gotpl
[convert] render convert.gotpl
[convert] render convert_input.gotpl
[convert] render filter.gotpl
gofmt failed on filter.go: generated/graphql/helpers/filter.go:373:110: expected selector or type assertion, found ')' (and 1499 more errors)
[resolver] get boiler models
[resolver] get models with information
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Lipid.Inventory
[WARN] boiler name not available for Recipe.Additives
[WARN] boiler name not available for Recipe.Batches
[WARN] boiler name not available for Recipe.Fragrances
[WARN] boiler name not available for Recipe.Lipids
[WARN] boiler name not available for Recipe.Steps
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Lye.Inventory
[WARN] boiler type not available for LyeInventory
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Fragrance.Inventory
[WARN] boiler type not available for AdditiveInventory
[WARN] boiler name not available for Supplier.AdditiveInventory
[WARN] boiler type not available for FragranceInventory
[WARN] boiler name not available for Supplier.FragranceInventory
[WARN] boiler type not available for LipidInventory
[WARN] boiler name not available for Supplier.LipidInventory
[WARN] boiler type not available for LyeInventory
[WARN] boiler name not available for Supplier.LyeInventory
[WARN] boiler name not available for RecipeBatch.Additives
[WARN] boiler name not available for RecipeBatch.Fragrances
[WARN] boiler name not available for RecipeBatch.Lipids
[WARN] boiler type not available for Lye
[WARN] boiler name not available for RecipeBatch.Lye
[WARN] boiler name not available for RecipeBatch.Notes
[WARN] boiler type not available for AdditiveInventory
[WARN] boiler type not available for FragranceInventory
[WARN] boiler type not available for Inventory
[WARN] boiler name not available for Additive.Inventory
[WARN] boiler type not available for AdditiveInventory
[WARN] boiler type not available for FragranceInventory
[WARN] boiler type not available for LipidInventory
[WARN] boiler type not available for LyeInventory
[WARN] boiler type not available for LipidInventory
[resolver] generate file
error!!
resolvergen: convert.gotpl: template: convert.gotpl:27:19: executing "convert.gotpl" at <$.Backend.Directory>: can't evaluate field Backend in type *gqlgen_sqlboiler.ResolverBuild
exit status 3
I'm going to scale back the schema and iterate on adding tables to see if I can find where things start breaking.
Thanks for helping, Ideally we would have a schema with al breaking things added to examples/
https://github.com/web-ridge/gqlgen-sqlboiler-examples
So we can make sure all cases work after a version update
Can you send my the sql of the table generation? info@webridge.nl so I can look into it this week
I started with a basic schema and adding models and was still running into issues.
I have emailed you a copy of my schema. I got caught up with work today and wasn't able to get much debugging in this evening, should have time tomorrow.
Thanks for the .sql file I'm reproducing this at: https://github.com/web-ridge/gqlgen-sqlboiler-examples/tree/main/issue-38-plugin-panics
The graphql schema is not right on the Update/Create inputs where it includes the relationships while there is no id in the input itself.
input FragranceUpdateInput {
recipeBatchFragrance: RecipeBatchFragrance # should not be here
recipeFragrance: RecipeFragrance # should not be here
}
I'll try to fix your example this week
I fixed most issues locally, thanks for providing the schema and the feedback so far! I'm still working on some extra fixes. Do you want the django_ tables in models and graphql_models too? Some tables of them don't have id's.
Cool, thanks for looking into this!
Whoops, I forgot to filter those tables out of the schema I sent you. I've just been using Django to manage migrations and for a simple admin interface. They can be ignored.
I'll release a new version this evening which generates your database schema correctly.
I'm not sure if the functionality on Fragrance will work correctly since the foreign key is not available in the struct itself. It would be nice if you could test out if
Here is the output so far: https://github.com/web-ridge/gqlgen-sqlboiler-examples/tree/main/issue-38-plugin-panics
New versions are released which should fix this issue. Thanks you for helping me to reproduce the issue 👌!
gqlgen-sqlboiler https://github.com/web-ridge/gqlgen-sqlboiler/releases/tag/v2.1.5 sqlboiler-graphql-schema https://github.com/web-ridge/sqlboiler-graphql-schema/releases/tag/v1.0.5
Don't forget to pin https://github.com/web-ridge/utils-go on the latest commit (I still need this to follow the gomodule version spec which is not te case yet, so sometimes it won't pin to the latest version)
Hey, trying out your library and experiencing a few issues. Looking for help debugging what's going on.
I'm assuming there is something strange with my DB schema (Postgres). Wondering if you can offer any advice on how to debug. Using this library will save me tons of time. Happy to dig in but thought you might see some obvious issues.
When I run the plugin I get the following
panic
There is panic is because
field.BoilerField.Relationship.Name
is nil. Should this ever happen? https://github.com/web-ridge/gqlgen-sqlboiler/blob/main/convert.go#L863I wrapped that line in a nil check to stop the panic but get the following error when I run the plugin again.
This is the plugin configuration
I used the
https://github.com/web-ridge/sqlboiler-graphql-schema
library is generate my graphql schema and got a similar nil error https://github.com/web-ridge/sqlboiler-graphql-schema/blob/main/main.go#L714relationType := boilerField.Relationship.Name
Which I changed torelationType := boilerField.RelationshipName
This change successfully generated a valid schema but needed a few edits to deal with pluralizations, and remove relationships that I didn't want to expose.
I could post the DB schema and graphql schema but the files are over 1000 lines.
Library is very cool. Glad to help out debugging!