Finding a blog post with Query for Expo and React Native
In this section, we will learn how to search for posts with a search bar and a simple GraphQL Query. Query looks for specific records in the database with GraphQL. Let's get started:
- Open the
App.tsx
file and add the followingfindPosts
code anywhere above thereturn
code block:const findPosts = async (title: string): Promise<any> => { Â Â Â Â try { Â Â Â Â Â Â console.log("finding posts:", title); Â Â Â Â Â Â const postData: any = await API.graphql( Â Â Â Â Â Â Â Â graphqlOperation(queries.listPosts, { Â Â Â Â Â Â Â Â Â Â filter: { Â Â Â Â Â Â Â Â Â Â Â Â title: { Â Â Â Â Â Â Â Â Â Â Â Â Â Â contains: title, Â Â Â Â Â Â Â Â &...