2

Apollo Client lets you directly execute queries for example.

import { ApiClient } from './index'
import gql from 'graphql-tag'

export const query = (data) => ApiClient.query({
  query: gql`
    query {
      users (user:"${data.id}") {
      name
    }      
  }
`
})
  .then(data => { return data.data.users })
  .catch(e => { return e })

I was wondering if anyone had experience writing Jest tests for these. All I've found is examples using react-apollo etc

1 Answer 1

2

If you just want to test your queries and mutations, I recommend testing that on the back end.

take a look at this article here: Testing GraphQL

Sign up to request clarification or add additional context in comments.

1 Comment

That link seems dead now - and the links in web archive are broken too web.archive.org/web/20220817155428/https://hackernoon.com/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.