gql-dart / ferry

Stream-based strongly typed GraphQL client for Dart
https://ferrygraphql.com/
MIT License
593 stars 113 forks source link

Custom ISO serializer for DateTime #572

Closed Inlustra closed 6 months ago

Inlustra commented 6 months ago

Hi, we're currently trying to parse a date time in ISO format. On the server the scalar name is DateTime

build.yaml

targets:
  $default:
    builders:
      ferry_generator|graphql_builder:
        enabled: true
        options:
          schema: package:my_app|lib/schema.graphql
          type_overrides:
            EmailAddress:
              name: String
            DateTime: 
              name: DateTime
          custom_serializers:
            - import: "package:my_app|lib/utils/date_time_deserializer.dart"
              name: DateTimeSerializer

      ferry_generator|serializer_builder:
        enabled: true
        options:
          schema: driver_app|lib/schema.graphql
          type_overrides:
            DateTime:
              name: DateTime

Unfortunately our date_time_serializer never gets used, could anyone lend some support?

knaeckeKami commented 6 months ago

here's an example of your use case:

https://ferrygraphql.com/docs/custom-scalars

Inlustra commented 6 months ago

@knaeckeKami That isn't working for us. We don't want to override the type and still want to use DateTime from dart:core. We just want to serialize it differently.

Am I missing something?

knaeckeKami commented 6 months ago

Yes, the custom_serializers is in the wrong place

Inlustra commented 6 months ago

Oh damn it, we have them around the wrong way.

🤦

Apologies, thank you for taking the time!

knaeckeKami commented 6 months ago

no worries, glad i could help