[SOLVED] Location Map JsonScalar Issues

hello, i am new at squidex. can you help me? i am facing some code issues. which is a map. when I am doing mutation in the map lat and lng data it’s getting a problem. can you explain how to fix these issues? it’s getting a JsonScaler problem. I checked already without myLocation Data. Without Mylocation Data it seems ok. same issue when I am creating data with location map data. I thing its a Structural issue.

I’m submitting a…

mutation (
  $ids: String
  $vehicle: [DriverDataVehicleChildInputDto!]
  $myLocation: JsonScalar
) {
  patchDriverContent(
    id: $ids
    data: { vehicle: { iv: $vehicle }, myLocation: { iv: $myLocation } }
    expectedVersion: -2
  ) {
    id
    flatData {
      name
      email
      license
      contactNumber
      myLocation
      isVerified
      vehicle {
        vehicleType
      }
    }
  }
}

variable

{
   "ids":"4e4d3c4e-1181-4508-b180-031d51407ada",
   "vehicle":[
      {
         "vehicleType":"car",
         "model":"e-324",
         "number":"3216587135",
         "level":"after verified Approved"
      }
   ],
   "myLocation":{
      "latitude":23.7339483,
      "longitude":90.3929252
   }
}

Current behavior

"message": "Variable '$myLocation' of type 'JsonScalar' used in position expecting type 'JsonScalar'."

Expected behavior

Must be saved value in the cloud

Minimal reproduction of the problem

there is saved flat data when I manually input it inside the cloud

{
    "name": "Mohammad Abdur Rahman",
    "email": "testdata@gmail.com",
    "license": "23847893rwyiwei",
    "contactNumber": "0600235196",
    "profilePicture": null,
    "vehicle": [
        {
            "vehicleType": "car",
            "model": "e-324",
            "number": "3216587135",
            "level": "after verified Approved"
        }
    ],
    "isVerified": null,
    "myLocation": {
        "latitude": 22.3752075,
        "longitude": 91.8348606
    }
}

Environment

I am using Squidex built in cloud. So env nothing change at all.

Others:
Please help me. all create and mutations ok. just when I am doing anything with location then facing JsonScalar issues.

Please format your code properly with code blocks.

**there is a query** 

mutation ($ids: String, $vehicle: [DriverDataVehicleChildInputDto!], $myLocation: JsonScalar) {
  patchDriverContent(
    id: $ids
    data: {vehicle: {iv: $vehicle}, myLocation: {iv: $myLocation}}
    expectedVersion: -2
  ) {
    id
    flatData {
      name
      email
      license
      contactNumber
      myLocation
      isVerified
      vehicle {
        vehicleType
      }
    }
  }
}

**and there is a variable** 

{
  "ids": "4e4d3c4e-1181-4508-b180-031d51407ada",
  "vehicle": [
    {
      "vehicleType": "car",
      "model": "e-324",
      "number": "3216587135",
      "level": "after verified Approved"
    }
  ],
  "myLocation": {
    "latitude": 23.7339483,
    "longitude": 90.3929252
  }
}

I have to debug it, I am not entirely sure, why it happens. Perhaps the JsonScalar does not work with variables?

I would test to inject the latitude and longitude as individual variables.

I think the problem is the format. because I am testing it, changing so many times different different variables. but it shows the same error message. but it’s ok when I am doing it manually doing input in the cloud dashboard.
Error Message is

{
  "errors": [
    {
      "message": "Variable '$myLocation' of type 'JsonScalar' used in position expecting type 'JsonScalar'.",
      "locations": [
        {
          "line": 1,
          "column": 25
        },
        {
          "line": 4,
          "column": 54
        }
      ],
      "extensions": {
        "code": "VARIABLES_IN_ALLOWED_POSITION",
        "codes": [
          "VARIABLES_IN_ALLOWED_POSITION"
        ],
        "number": "5.8.5"
      }
    }
  ],
  "extensions": {
    "tracing": {
      "version": 1,
      "startTime": "2024-04-29T11:05:15.4322087Z",
      "endTime": "2024-04-29T11:05:15.4331715Z",
      "duration": 962800,
      "parsing": {
        "startOffset": 300,
        "duration": 432599
      },
      "validation": {
        "startOffset": 434599,
        "duration": 520000
      },
      "execution": {
        "resolvers": []
      }
    }
  }
}

It sounds more like a bug to me.

Can you please help me to fix this !

As I said: I need to investigate it.

Have you tried my suggestion?

I would test to inject the latitude and longitude as individual variables.

Yes, I tired but it’s getting the same error.

Can you show me what you made?

I can reproduce the bug and fix it. Tomorrow is a public holiday in Germany, therefore I won’t deploy today or tomorrow, but very likely this Thursday.

1 Like

Can you give me a sample mutation query for geolocation, please? It helps me a lot. Which we can test easily through Graphiql. There is an option in the API tab.

Thanks a lot. Brother!

Perhaps just without variables?

mutation ($id: String) {
  patchDriverContent(
    id: $id
    data: { myLocation: {iv: {
   latitude: 23,
   longitude: 13
}}}
    expectedVersion: -2
  ) {
    id
  }
}
1 Like

without a variable it’s working thanks … now can you give me a do with the variable ?? I mean latitude and longitude used as a dynamic data

No, it does not work, because location is a scalar, a single value so the speak.