GraphQL Cookbook
Finding objects
10 min
finding objects through the parse graphql api problem you want to find objects from your database through the parse graphql api solution using the parse graphql, there are two different ways to find objects from your database using generic query https //www back4app com/docs/parse graphql/graphql query find objects#query generic this is the query that you can use to find objects of any class using class query https //www back4app com/docs/parse graphql/graphql query find objects#query class this is the recommended query that you should use to find objects of a specific class version information depending on the version of parse you choose to run, the graphql queries, mutations and results will be slightly different please choose the correct example along with the parse version you are running using generic query when you use the find find generic query, parse server behaves like a schemaless database it means that you do not need to specify which object’s fields you want to retrieve you just need to send the object’s classname classname , and parse server will return all fields of the found objects therefore, the objects’ find find generic query is the query that you can use for finding objects of any class if you want to find objects of a specific class, we recommend using the class query https //www back4app com/docs/parse graphql/graphql query find objects#query class this example will only work if you use a classname classname with existing object you can create an object using the creating an object recipe parse server 3 8 0 request 1 query findobject { 2 find(classname "hero") { 3 count, 4 results 5 } 6 } response 1 { 2 "data" { 3 "find" { 4 "count" 2, 5 "results" \[ 6 { 7 "objectid" "rr8jmfrnks", 8 "name" "luke skywalker", 9 "createdat" "2019 11 04t12 42 40 723z", 10 "updatedat" "2019 11 04t12 42 40 723z" 11 }, 12 { 13 "objectid" "tuecddcgno", 14 "name" "r2 d2", 15 "createdat" "2019 11 04t12 44 10 951z", 16 "updatedat" "2019 11 04t12 44 10 951z" 17 } 18 ] 19 } 20 } 21 } example 3 9 0 and later parse 3 9 0 and later does not have the generic methods get and find you must use the specific methods below to retrieve objects using class query once you have already created your object’s class in your application’s schema (for instance, using the creating an object https //www back4app com/docs/parse graphql/graphql mutation create object#mutation generic recipe), parse server instantly adds to your graphql api a new find\<classname> find\<classname> query to find objects of this class therefore, the object’s class query is the recommended method for finding objects of a specific class since this query knows your class’ data, it will automatically make available for you additional features like code auto complete and validation this example will only work if you use a class' query of existing object you can create an object using the creating an object recipe parse server 3 10 0 and later request 1 query findhero { 2 heroes{ 3 count, 4 edges{ 5 node{ 6 name 7 createdat 8 updatedat 9 } 10 } 11 } 12 } response 1 { 2 "data" { 3 "heroes" { 4 "count" 3, 5 "edges" \[ 6 { 7 "node" { 8 "name" "luke skywalker", 9 "createdat" "2020 02 06t13 02 33 652z", 10 "updatedat" "2020 02 06t13 02 33 652z" 11 } 12 }, 13 { 14 "node" { 15 "name" "r2 d2", 16 "createdat" "2020 02 06t13 13 26 678z", 17 "updatedat" "2020 02 06t13 13 26 678z" 18 } 19 } 20 ] 21 } 22 } 23 } older parse server versions parse 3 9 0 class query request 1 query findhero { 2 heroes{ 3 count, 4 results { 5 id, 6 name, 7 createdat, 8 updatedat 9 } 10 } 11 } response 1 { 2 "data" { 3 "heroes" { 4 "count" 2, 5 "results" \[ 6 { 7 "id" "ckhurmmjzw", 8 "name" "luke skywalker", 9 "createdat" "2019 11 04t12 37 22 462z", 10 "updatedat" "2019 11 04t12 37 22 462z" 11 }, 12 { 13 "id" "n5grpei0il", 14 "name" "r2 d2", 15 "createdat" "2019 11 04t12 45 00 882z", 16 "updatedat" "2019 11 04t12 45 00 882z" 17 } 18 ] 19 } 20 } 21 } parse server 3 8 0 class query request 1 query findhero { 2 heroes{ 3 count, 4 results { 5 objectid, 6 name, 7 createdat, 8 updatedat 9 } 10 } 11 } response 1 "data" { 2 "objects" { 3 "findhero" { 4 "count" 2, 5 "results" \[ 6 { 7 "objectid" "ffyobotk85", 8 "name" "luke skywalker", 9 "createdat" "2019 07 15t01 25 20 875z", 10 "updatedat" "2019 07 15t01 25 20 875z" 11 }, 12 { 13 "objectid" "jjh0aqqjfs", 14 "name" "r2 d2", 15 "createdat" "2019 07 15t02 22 04 982z", 16 "updatedat" "2019 07 15t02 22 04 982z" 17 } 18 ] 19 } 20 } 21 } 22 } parse server 3 7 2 generic query request 1 query findobject { 2 objects { 3 find(classname "hero") { 4 count, 5 results 6 } 7 } 8 } response 1 { 2 "data" { 3 "objects" { 4 "find" { 5 "count" 2, 6 "results" \[ 7 { 8 "objectid" "ffyobotk85", 9 "name" "luke skywalker", 10 "createdat" "2019 07 15t01 25 20 875z", 11 "updatedat" "2019 07 15t01 25 20 875z" 12 }, 13 { 14 "objectid" "jjh0aqqjfs", 15 "name" "r2 d2", 16 "createdat" "2019 07 15t02 22 04 982z", 17 "updatedat" "2019 07 15t02 22 04 982z" 18 } 19 ] 20 } 21 } 22 } 23 } class query request 1 query findhero { 2 objects { 3 findhero { 4 count, 5 results { 6 objectid, 7 name, 8 createdat, 9 updatedat 10 } 11 } 12 } 13 } response 1 "data" { 2 "objects" { 3 "findhero" { 4 "count" 2, 5 "results" \[ 6 { 7 "objectid" "ffyobotk85", 8 "name" "luke skywalker", 9 "createdat" "2019 07 15t01 25 20 875z", 10 "updatedat" "2019 07 15t01 25 20 875z" 11 }, 12 { 13 "objectid" "jjh0aqqjfs", 14 "name" "r2 d2", 15 "createdat" "2019 07 15t02 22 04 982z", 16 "updatedat" "2019 07 15t02 22 04 982z" 17 } 18 ] 19 } 20 } 21 } 22 }