Skip to content

Instantly share code, notes, and snippets.

@danedavid
Created March 7, 2019 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danedavid/4b2ef637695283ee794a63eed4f019ce to your computer and use it in GitHub Desktop.
Save danedavid/4b2ef637695283ee794a63eed4f019ce to your computer and use it in GitHub Desktop.
import { GraphQLClient } from 'graphql-request';
const client = new GraphQLClient('http://localhost:4000/api');
const handleSearch = (value) => {
client.request(/* GraphQL */`
query getBookList($search: String!) {
search(searchString: $search) {
count
books {
id
title
authors
pageCount
imageLinks {
small
}
}
}
}
`, {
'search': value,
})
.then(data => {
setData(data);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment