Describe the bug
When I set queries: null on @model but I define a @key with a queryField, the ModelContentCategoryConnection is not compiled.
type ContentCategory @model(queries: null, mutations: { create: "addContentToCategory", delete: "deleteContentFromCategory"})
@key(name: "ContentByCategory", fields: ["category", "type", "language", "datetime"], queryField: "listContentByCategory")
{
id: ID!
category: Int!
datetime: String!
type: ContentType!
language: Language!
content: Content @connection
}
This is compiled:
type Query {
listContentByCategory(category: Int, typeLanguageDatetime: ModelContentCategoryContentByCategoryCompositeKeyConditionInput, sortDirection: ModelSortDirection, filter: ModelContentCategoryFilterInput, limit: Int, nextToken: String): ModelContentCategoryConnection
}
However, the ModelContentCategoryConnection input is missing in the compiled schema.
Workaround
type ContentCategory @model(queries: { list: "listContentCategories"}, mutations: { create: "addContentToCategory", delete: "deleteContentFromCategory"})
@key(name: "ContentByCategory", fields: ["category", "type", "language", "datetime"], queryField: "listContentByCategory")
Adding a query (or removing the null of course) fixes the generation of the model.
Expected behavior
A model to be generated if the only query added is via @key.
@BabyDino what version of the CLI are you using? Could you please try to repro it with the latest version and get back to us?
@attilah I've just tested it with the latest release (3.11.0). The problem still exists.
Schema Creation Status is FAILED with details: Found 1 problem(s) with the schema: The field type 'ModelCategoryCategoryConnection' is not present when resolving type 'Query'
@attilah I'm still seeing this happens when also using a @key widthqueryField and setting queries: null on 4.24.3.
Documentation is weak on this, not sure if there's a specific way to set this, but I did try with { get: "getMyModel" } and that also failed on push.
This happens no matter how I try, I also tried queries: { list: null } with the same result. This model has public access, so I'm interested in removing listing as it should only be accessible to read by the @key based query.
Error:
AWS::AppSync::GraphQLSchema Wed Jul 22 2020 23:58:32 GMT-0500 Schema Creation Status is FAILED with details: Found 1 problem(s) with the schema: The field input type 'ModelRedirectFilterInput' is not present when resolving type 'Query' [@1475:1]
With that it seems there's no way to use only a @key and have all other queries removed in the current latest version of Amplify.
If I remove the auto-generated query I am able to use the @key directive without any issues. Seems like the generated query depends on the Filter Input which is generated by @model directive unless it is turned off.
So, I have this, which works for me:
type Foo
@model(queries: null)
@key(name: "fooKey", fields: ["hash", "sort"], queryField: null)
+1 I'm getting similar error and filed https://github.com/aws-amplify/amplify-cli/issues/6029 for it.
Most helpful comment
@attilah I'm still seeing this happens when also using a @key width
queryFieldand settingqueries: nullon 4.24.3.Documentation is weak on this, not sure if there's a specific way to set this, but I did try with
{ get: "getMyModel" }and that also failed on push.