Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

The value of $input has a wrong structure., Location: [object Object], Path: undefined

$
0
0

I am trying to run a graphql mutation. On the playground, it works like this:

mutation {  addFavouritePlace(    input: {      center: { coordinates: [4, 9], type: POINT },      customisedName: "School",      placeName: "Schonebeck"    }  ) {    id  }}

In my code, I am trying to run it like this:

mutation addFavouritePlace($input: AddFavouritePlaceInput!) {  addFavouritePlace(input: $input) {    id  }}...  const [addFavouritePlace, { data, error }] = useAddFavouritePlaceMutation({    onCompleted: () => {      console.log('yas');      console.log('HDUIAJS', data);    },    onError: () => {      console.log('nooo');      console.log('HDUIAJS', error);    },  });..        addFavouritePlace({          variables: {            input: {              center: {                coordinates: [8,8],                type: GeoJsonGeometryType.Point,              },              customisedName: 'NewSchool',              placeName: "Bremen Hbf 34"            },          },        });

However, I keep getting an error that:

The value of $input has a wrong structure., Location: [object Object], Path: undefined. The error from console.log('HDUIAJS', error); undefined though.

I am certain that the $input: AddFavouritePlaceInput! is correct. Where else could I be going wrong?

Edit:

On the playground, the above mutation would work. However, if I change it to:

mutation addFavouritePlace($input: AddFavouritePlaceInput!) {  addFavouritePlace(input: $input) {    id  }}

and write this in the query variables section:

{"input": {"center": {"coordinates":[4,5],"type": "POINT"},"customisedName": "NewLoc", "placeName": "Sheesh"}}

I get the same error because of the coordinates field. Epected value type of Position. Now Position is simply defined as an array of numbers. Which is exactly what I am passing.


Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>