zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 620 forks source link

DateTime is not getting convert to the Graphql Type Date #1175

Closed kunalgharate closed 2 years ago

kunalgharate commented 2 years ago

Error

_RequestFormatException(originalException: Converting object to an encodable object failed: LinkedHashSet len:1, request: Request(operation: Operation(document: DocumentNode("mutation($country: String!, $insuranceProvider: String!, $memberId: String, $cardNumber: String!, $plan: String!, $validFrom: Date!, $validTo: Date!, $status: String!, $cardImage: String) {\n typename\n createInsurance(patientId: \"10\", content: {country: $country, insuranceProvider: $insuranceProvider, memberId: $memberId, cardNumber: $cardNumber, plan: $plan, validFrom: $validFrom, validTo: $validTo, status: $status, cardImage: $cardImage}) {\n typename\n id\n patientId\n country\n insuranceProvider\n memberId\n cardNumber\n plan\n validFrom\n validTo\n status\n cardImage\n createdAt\n updatedAt\n }\n}"), operationName: null), variables: {patientId: 10, content: {{{country: dfjsdjfs, insuranceProvider: dsdsjfsjfsng, memberId: Strijdcsjcsng, cardNumber: dvjscvjs, plan: jdjf, validFrom:

Schema

mutation ($country: String!, $insuranceProvider: String!, $memberId: String, $cardNumber: String!, $plan: String!, $validFrom: Date!, $validTo: Date!, $status: String!, $cardImage: String) {
  createInsurance(patientId: "10", content: {country: $country, insuranceProvider: $insuranceProvider, memberId: $memberId, cardNumber: $cardNumber, plan: $plan, validFrom: $validFrom, validTo: $validTo, status: $status, cardImage: $cardImage}) {
    id
    patientId
    country
    insuranceProvider
    memberId
    cardNumber
    plan
    validFrom
    validTo
    status
    cardImage
    createdAt
    updatedAt
  }
}

**// Passing data** 

document: gql(InsuranceSchema.addInsuranceSchema),
        variables: {
          'patientId': '10',
          // 'content': patientInsuranceInput.toJson()
          'content': {
            {
              {
                "country": "dfjsdjfs",
                "insuranceProvider": "dsdsjfsjfsng",
                "memberId": "Strijdcsjcsng",
                "cardNumber": "dvjscvjs",
                "plan": "jdjf",
                "validFrom": graphQLDate.serialize(DateTime.now()),
                "validTo": graphQLDate.serialize(DateTime.now()),
                "status": "jssfj",
                "cardImage": "gsjgsj"
              }
            }
          }
        }));

I want to insert date. to the graphql but it's not working with flutter

ins
vincenzopalazzo commented 2 years ago

please provide a more well-format example! it is unreadble

kunalgharate commented 2 years ago

@vincenzopalazzo please check I have the question. if you need more help please let me know

kunalgharate commented 2 years ago

@vincenzopalazzo would you like to help me with Date insertion using mutation I want to know how to insert date

vincenzopalazzo commented 2 years ago

the problem in how you pass the string, and also are you sure that you are suing graphql_flutter? if yes, please check how we pass the variable!

vincenzopalazzo commented 2 years ago

https://github.com/zino-hofmann/graphql-flutter/tree/main/packages/graphql

vincenzopalazzo commented 2 years ago

NP. in your query parameter there is no content variable.

I'm going to close this issue, if you have a complete example that I can reproduce I'm happy to help!

Otherwise if you a seeking help try discord or github discussion