This link allows to log GraphQL queries for debugging purposes. So far it has been tested on the server and on the client side using a repo talking to https://fakerql.com/. Local tests are to come.
npm install apollo-link-log-query
Import and compose with other links using ApolloLink.from
.
On the server side, go like this:
;;;;;;; const client = link: ApolloLink cache: ; client ;
On the client side, go like this:
;;;;;;;;;; const client = link: ApolloLink cache: ; const Users = <Query query=gql` query Users { allUsers(count: 1) { id firstName lastName } } ` > { if loading return <p>Loading...</p>; if error return <p>Error :</p>; return dataallUsers; }} </Query>; const App = <ApolloProvider client=client> <> <h2>My cool Apollo app! 🚀</h2> <Users/> </> </ApolloProvider>; ;
CHECKLIST
- update README with a descripton, installation instructions, and an example of usage
- set up compilation with Babel 7
- use babel-preset-env
- set browserslist according to best practices
- use
watch
for development, add an npm script - verify that the transpiled code works on the server side
- verify that the transpiled code works on the client side
- set up type checking with TypeScript
- write tests (see tests for apollo-link-http and this article on mocking)
- double-check the
main
field in package.json - set up the
prepublish(Only)
script - add
.npmignore