Graphql apollo-client useMutation variable with gql , GraphQLInputObjectType does not check for input object fields

Viewed 124

could anyone please help me understand on how to validate the input argument object type on apollo client , i am trying to make sure that passing additional fields on the input object fails the query . But it works even if i pass additional fields (Note : I want the validation on front end and not on the server)

const mutationInput = new GraphQLObjectType({
    name: 'mutationInput',
    fields: {
        Id: String,
        statusCode: String,
    }
});

const GET_DATA = gql`
  mutation($in: ${mutationInput}!){
    getData(in: $in) {
      status
      }
    }
  }`;

//usage 
const [getData, { error,loading }] = useMutation(
    GET_DATA,
    {
       ...
     }
   )

  getData({
      variables: {
        in: {
           statusCode:"OK",
           ID:"azz12",
           extraField:"some value" //Validation needs to fail as this field is not defined on input object, but never fails on front end
         }
      }

0 Answers
Related