Describe the bug
amplify api gql-compile
with amplify cli 4.21.3 result lacks filter input definitions, therefore amplify push api
failed.
amplify cli 4.18.0 I used before, it doesn't happen.
Amplify CLI Version
4.21.3
To Reproduce
Schema definition (minimum to reproduce)
type Group
@model(
mutations: { create: null, update: null, delete: null },
queries: { get: null, list: null },
subscriptions: null
)
@key(name: "ByKey", fields: ["key"], queryField: "listGroupsByKey")
{
id: ID!
key: String!
}
With amplify cli version 4.21.3
, amplify api gql-compile
generates:
type Group {
id: ID!
key: String!
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
type Query {
listGroupsByKey(key: String, sortDirection: ModelSortDirection, filter: ModelGroupFilterInput, limit: Int, nextToken: String): ModelGroupConnection
}
type ModelGroupConnection {
items: [Group]
nextToken: String
}
With amplify cli version 4.18.0
, amplify api gql-compile
generates:
type Group {
id: ID!
key: String!
}
input ModelStringFilterInput {
ne: String
eq: String
le: String
lt: String
ge: String
gt: String
contains: String
notContains: String
between: [String]
beginsWith: String
}
input ModelIDFilterInput {
ne: ID
eq: ID
le: ID
lt: ID
ge: ID
gt: ID
contains: ID
notContains: ID
between: [ID]
beginsWith: ID
}
input ModelIntFilterInput {
ne: Int
eq: Int
le: Int
lt: Int
ge: Int
gt: Int
between: [Int]
}
input ModelFloatFilterInput {
ne: Float
eq: Float
le: Float
lt: Float
ge: Float
gt: Float
between: [Float]
}
input ModelBooleanFilterInput {
ne: Boolean
eq: Boolean
}
input ModelGroupFilterInput {
id: ModelIDFilterInput
key: ModelStringFilterInput
and: [ModelGroupFilterInput]
or: [ModelGroupFilterInput]
not: ModelGroupFilterInput
}
type Query {
listGroupsByKey(key: String, sortDirection: ModelSortDirection, filter: ModelGroupFilterInput, limit: Int, nextToken: String): ModelGroupConnection
}
type ModelGroupConnection {
items: [Group]
nextToken: String
}
Expected behavior
To get the same result with amplify cli 4.18.0
.
Screenshots
N/A
Desktop (please complete the following information):
Additional context
I want to know whether I mistake the way of writing schema or some bug of cli.
@rinosamakanata thanks for reporting the issue, it seems to be a regression from a recent @key change and it happens because in the schema the queries are disabled and @key
transformer is not aware of the regular CRUD operations, that is added by the @model
transformer.
@attilah thanks! I now understand why this problem occurs. I am hopeful that it will be resolved in the near future.
Due to this issue we are unable to upgrade to the latest version of the CLI... Do you have an update scheduled?
Hi @rinosamakanata
The fix has been deployed in previous versions. Can you try with latest amplify version?
Let us know if this works for you?
Hi @akshbhu
I tried amplify api gql-compile
with the latest version and it worked.
ModelXxxFilterInput types are appeared successfully in the compiled schema.graphql file.
Thank you very much for fixing the bug.
Now we can finally upgrade the CLI!
Most helpful comment
@rinosamakanata thanks for reporting the issue, it seems to be a regression from a recent @key change and it happens because in the schema the queries are disabled and
@key
transformer is not aware of the regular CRUD operations, that is added by the@model
transformer.