Skip to content

Instantly share code, notes, and snippets.

@michaljemala
Created October 13, 2016 12:30
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 michaljemala/545fb0615f2f423a0f76da87b4f0f97a to your computer and use it in GitHub Desktop.
Save michaljemala/545fb0615f2f423a0f76da87b4f0f97a to your computer and use it in GitHub Desktop.
# Population with filter for particular period:
query UK {
node(id: "0491") {
label(lang: "en")
population(filter: "$point_in_time == `2010`") @propagate
}
}
# List of genders using the gender ID
query GenderNode {
node(id: "fdfa21d166") {
instance_of@reverse {
label(lang: "en")
}
}
}
# or Wikidata Q identifier
query GenderWikidataID {
node(val: "iQ48277") {
wikidata_id @reverse {
instance_of @reverse {
label(lang: "en")
}
}
}
}
# Traversal by value: "ten@Boston"
query BostonCitiesInUSA {
node(val: "ten@Boston") {
label @reverse {
id
located_in_the_administrative_territorial_entity @propagate {
located_in_the_administrative_territorial_entity @propagate {
located_in_the_administrative_territorial_entity @propagate {
label(lang: "en", filter: "$0 == `United States of America`") @propagate
}
}
}
instance_of @propagate {
wikidata_id(filter: "$0 == `Q515`") @propagate
}
}
}
}
# Limiting the number of results returned
query LimitCitizenshipsInTheUSA{
node(id: "041e") {
country: label(lang: en)
country_of_citizenship (limit: 3) @reverse {
person: label(lang: en)
id
}
}
}
# Getting information about all properties and their values of a node
query NYCInfo {
node(val: "iQ60") {
wikidata_id @reverse {
info
}
}
}
# Executing multiple queries at once
query NYC {
node(val: "iQ60") {
wikidata_id @reverse {
label(lang: en)
}
}
}
query Paris {
node(val: "iQ90") {
wikidata_id @reverse {
label(lang: fr)
}
}
}
query Tokyo {
node(val: "iQ1490") {
wikidata_id @reverse {
label(lang: ja)
}
}
}
# Filtering by type
query CountryIran {
node(val: "ten@Iran") {
label @reverse {
id
instance_of @propagate {
wikidata_id(filter: "$0 == `Q6256`") @propagate
}
}
}
}
# Simplify queries with (nested) fragments
fragment name_id {
id
label(lang: en)
}
fragment man_data {
...name_id
place_of_birth {
...name_id
}
sex_or_gender {
...name_id
}
occupation {
...name_id
}
country_of_citizenship {
...name_id
}
}
query BillClinton {
node(id: "fdfa2a4dd0") {
...man_data
}
}
query LarryPage {
node(id: "fdfa04ed7b") {
...man_data
}
}
# Get the movies in which Angelina Jolie acted:
query AngelinaMovies {
node(val: "ten@Angelina Jolie") {
label @reverse {
wikidata_id
cast_member @reverse {
label.en
}
}
}
}
# The movies in which Kevin Bacon acted and the actors he acted with in them:
query KevinBacon {
node(val: "iQ3454165") {
kevin: wikidata_id @reverse {
kevins_name: label.en
kevins_movies: cast_member @reverse {
label.en
other_actors: cast_member {
label.en
}
}
}
}
}
# List of movies released on the 23rd of December 2010 and during entire December of 2010.
query MoviesOn20101223 {
node(val: "d2010-12-23") {
movies: publication_date @reverse {
id
label.en
instance_of @propagate {
wikidata_id(filter: "$0 == `Q11424`") @propagate
}
}
}
}
#query MoviesOn20101223_WillTimeout_StartingWithVeryRichNode {
# node(val: "iQ11424") {
# wikidata_id @reverse {
# movies: instance_of @reverse {
# publication_date(filter: "$0 == `2010-12-23`") @propagate
# id
# label.en
# }
# }
# }
#}
# Search for "Monaco" in English, where it can be either a city or a country:
#query MonacoNotYetSupportedAsThereIsNoVALTYPIndexGenerated {
# node(val: "ten@Monaco", type: "location.country, location.citytown") {
# id
# }
#}
query Monaco {
node(val: "ten@Monaco") {
label @reverse {
id
instance_of @propagate {
wikidata_id(filter: "$0 == `Q6256` or $0 == `Q515`") @propagate
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment