If I use a field description like @db(index: 1) written in a single line like:
""" @model """
type Comment {
id: ID!
"""
@db(index: 1)
"""
text: String
description: String
}
buildModelTableMap gives: Can't parse annotation index: 1): Unexpected token ')'
To reproduce:
Use above schema in any template then yarn develop
I think we are mixing annotations with directives.
Once you use one type of the key like annotation for db.
We cannot use another type. So we need to:
A) Pick different key
B) Use the same type from graphql-metadata package
I'm in favour of using different key, I would prefer if we move away from the @db namespace as it is too generic and makes annotations hard to extend in future without adding breaking changes.
Look at the following example:
@db(index: 1)
How do you add more index properties in the future? You can't unless you do:
@db(index: 1, index_unique: true)
which is bad and will be a nightmare for users.
But if index is the namespace this becomes much easier:
@index(
name: 'my_index',
unique: true,
expiresAfterSeconds: 3600,
collationDocument: {
locale: 'en_IE'
}
)
I'm in favour of using different key, I would prefer if we move away from the
@dbnamespace as it is too generic and makes annotations hard to extend in future without adding breaking changes.Look at the following example:
@db(index: 1)How do you add more index properties in the future? You can't unless you do:
@db(index: 1, index_unique: true)which is bad and will be a nightmare for users.
But if
indexis the namespace this becomes much easier:@index( name: 'my_index', unique: true, expiresAfterSeconds: 3600, collationDocument: { locale: 'en_IE' } )
+100.
Closing. We will be using new namespace for index. parseAnnotations is deprecated and we will migrate all annotations to use parseMarker format.
Most helpful comment
I'm in favour of using different key, I would prefer if we move away from the
@dbnamespace as it is too generic and makes annotations hard to extend in future without adding breaking changes.Look at the following example:
How do you add more index properties in the future? You can't unless you do:
which is bad and will be a nightmare for users.
But if
indexis the namespace this becomes much easier: