Hello Freebase MQL ! ... well, close enough :)

Good Job Sean !


On Thu, Sep 14, 2017 at 10:11 AM Sean Lee <iseansay@gmail.com> wrote:
Hi,

I'd like to share a small project I've done for last couple of week.

I've building last couple of my projects's backend api in GraphQL (http://graphql.org/ ), which is a new query language specification started by Facebook  It solved many problem in the modern web application developing, read their website for more if you're interested.

In the mean time, I'm really interested in using wikidata's structured data for some of my scripts and toy projects. It seems to me somehow we could comebine these two to provide an easy to use API for application users. 

So here's the simple demo using GraphQL to querying the wikidata, it's just a prove of concept certainly not ready for any serious use. The underlying fetching it's done by using the rest API at https://www.wikidata.org/w/api.php

Demo time: you could write some query to

1. Get the beatles's all members(has_part) 's award_received and  place_of_birth and twitter_username

(permalink for this query at http://bit.ly/2eXTmbG )

{
  entity(id: "Q1299") {
    label(lang: "en")
    has_part {
      mainsnak {
        label(lang: "en")
        award_received {
          mainsnak {
            label(lang: "en")
          }
        }
        place_of_birth {
          mainsnak {
            label(lang: "en")
          }
        }
        twitter_username {
          mainsnak
        }
      }
    }
  }
}


2. Get China's all past head_of_government and where they educated_at and what other position_held before

(permalink for this query at http://bit.ly/2xmxaT1 )

{
  entity(id: "Q148") {
    label(lang: "en")
    head_of_government {
      mainsnak {
        label(lang: "en")
        educated_at {
          mainsnak {
            id
            label(lang: "en")
          } 
        }
        position_held {
          mainsnak {
            label(lang: "en")
          } 
        }
      }
    }
  }
}


You could visit here to use the api explorer to write some query to try this one

http://wikidata.notimportant.org/graphql


Certainly there is so much to do in order to get most of wikidata:

1. need add reference and qualifiers
2. support search entity
3. other datatype like Time and Media, Geographic and etcs to the graphql schema
4. and maybe many things  to help make reverse lookup possible (like get one artist's all albums)

Also I realized this certainly can't do a lot of things that SPARQL does, but in a way it provide a more intuitive way to get many useful data needed out of wikidata. And it's really expressive for deep nested info compare to the what we have. It's still an early project, ideas and comments are welcome.
 
Source code available:  https://github.com/seansay/wikidata-graphql

--
Best,
李松, Sean Lee
_______________________________________________
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata