sdk-for-dart icon indicating copy to clipboard operation
sdk-for-dart copied to clipboard

Why are parameters not strongly typed ?

Open orevial opened this issue 4 years ago • 2 comments

👟 Reproduction steps

Not really a bug but I was wondering if there was a specific reason to not add strongly typing to all services parameters ?

Examples for database service :

Future<models.DocumentList> listDocuments(
      {required String collectionId,
      List? filters,
      int? limit,
      int? offset,
      String? orderField,
      String? orderType,
      String? orderCast,
      String? search})

where filters list is not typed, or :

Future<models.Document> createDocument(
      {required String collectionId,
      required Map data,
      List? read,
      List? write,
      String? parentDocument,
      String? parentProperty,
      String? parentPropertyType})

where data, read and write are not typed either.

Same goes for certain responses that simply return a Response or sometimes just an untyped Future.

This makes the SDK really hard to use as we have to always refer to the documentation and hope that stuff we are looking for is defined there.

👍 Expected behavior

As a developer, I would expect following typing for examples above:

Future<models.DocumentList> listDocuments(
      {required String collectionId,
      List<Filter>? filters,
      int? limit,
      int? offset,
      String? orderField,
      String? orderType,
      String? orderCast,
      String? search})

where filters list is not typed, or :

Future<models.Document> createDocument(
      {required String collectionId,
      required Map<String, dynamic> data,
      List<Rule>? read,
      List<Rule>? write,
      String? parentDocument,
      String? parentProperty,
      String? parentPropertyType})

👎 Actual Behavior

Many methods are not strongly typed as explained in introduction.

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

MacOS

🧱 Your Environment

Tested on AppWrite 0.11.0 with following Dart packages:

  • appwrite: ^2.0.3
  • dart_appwrite: ^1.0.2

(similar problems for Dart or Flutter package).

👀 Have you spent some time to check if this issue has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

orevial avatar Nov 19 '21 10:11 orevial

The new Dart SDK with structured response models is now available: https://dev.to/appwrite/announcing-appwrite-dart-sdk-20-50a1

Strong typed DB filters will be introduced with the release of Appwrite 0.12

eldadfux avatar Dec 22 '21 03:12 eldadfux

@orevial Thank you for your issue. We are aware of this. As our SDKs are generated using Swagger specs using our sdk-generator, there are certain limitations at the moment. But we are working to improve typing for Map and List param as well

lohanidamodar avatar Dec 26 '21 05:12 lohanidamodar

How is this going? I second this ticket.

TheMaverickProgrammer avatar Jun 04 '23 02:06 TheMaverickProgrammer

@orevial @TheMaverickProgrammer Most of the issues have already been resolved in the latest version of the SDK. If you still find some params missing proper type definition (except the data attribute in the createDocument method for now), please let us know and we will try to resolve it as soon as possible. Thank you.

lohanidamodar avatar Jun 04 '23 08:06 lohanidamodar

Closing this issue as it should already be resolved. If you still have the issues feel free to reopen.

lohanidamodar avatar Jun 22 '23 05:06 lohanidamodar