mst-gql
mst-gql copied to clipboard
Casing issues in the generated code
I have a GraphQL type named as "FileContent", the generated props collection in the RootStore was "fileContents" but during merge it was looking for a prop "filecontents" on the RootStore (with a small c).
Any quick hints where to look for it?
I'm guessing this is due to a bug related to the new naming that @beepsoft worked on. I would start looking at the changes in this PR first: https://github.com/mobxjs/mst-gql/pull/155
Who ever looks at this should add a test if at all possible!
@sanketsahusoft Can you maybe share your graphql schema?
@sanketsahusoft Can you maybe share your graphql schema?
And also provide the parameters you used for generating the mst models, please!
@sanketsahusoft One thing that worth checking is whether the mst-gql you use to generate the schema and the one that you use at runtime (at the time executing the queries) are of the same version. I created a test with a simple graphql model like this:
type Query {
files: [FileContent]!
}
type FileContent {
id: ID
text: String!
path: String!
}
and it seems to correctly generate fileContents root map, and when I do a files query the merge correctly tries to store it in the fileContents field.
The generator now has 2 modes: the default mode is to generate names according to Javascript naming conventions, the other mode (--dontRenameModels) will generate names as found in your graphql schema. If you use the default Javascript naming convention mode, then at runtime for a model named FileContent it will look for a root map fileContents, while in --dontRenameModels mode it would look for filecontents. This is also the naming convention used in mst-gql up to version 0.7.1.
So, in case you somehow generate your models with version 0.10.0 but have 0.7.1 at runtime then the root field naming convention will be different and you end up with the error you described. But this is only my hypothesis until you can provide some more detail, or maybe an example project resulting in this error.
Thanks, @beepsoft @chrisdrackett! I will try the --dontRenameModels flag.
@sanketsahusoft Also, if you upgraded from an earlier version of mst-gql (eg. from 0.7.1 to 0.10.0) you may have to regenerate all model files using --force. WARNING: this would overwrite any customizations you added to RootStore.ts and any model files, which are extended from the .base.ts files, so take care with that.
@beepsoft I am on 0.7.1. I didn't realize when 0.10.0 went live. Let me see! Thanks again!