Apollo mutation input type error

Hello, Im trying to create a mutation using apollo in my web app but I’m getting the error below
Error: “variable $post must have an input type”

Below is the mutation

export const ADD_POST = gql`
mutation CreateTPost($post: CreateTPostInput!) {
  createTPost(input: $post) {
    document {
      id
    }
  }
}
`

and in my component I’m calling it below

    const [addPost, { data, loading, error }] = useMutation(ADD_POST);
    addPost({
      variables: {
          post: {
              content: {
                  creator: "did:key:here_is_did_key",
                  date: "2023-03-18T12:00:43.093Z",
                  content: "new content"
              }
          }
      }
  })

I’ve tried copying the exact mutation above in graphiql and I was able to successfully create the post

can’t seem to find any resources online with this error
thanks

alright. I was doing something dumb. My Apollo Client has two different links to two different endpoints (graphql and ceramic) and I was pointing to graphql the whole time

 const client = new ApolloClient({
                cache: new InMemoryCache(), link: ApolloLink.split(
                    operation => operation.getContext().clientName === "ceramic", 
                    apolloLink, // <= apollo will send to this if clientName is "third-party"
                    graphQLLink // <= otherwise will send to this
                )
            })

Glad you found the solution @teddy and thank you for posting an update here! This might help other devs who encounter similar issues :slight_smile:

1 Like