PID Graph GraphQL Example Query by Funder

User story

As a funder, I want to search all research outputs (including publications, datasets and software) funded by us, so that I can find relevant work that we funded.

Query strategy

We use the Crossref Funder ID to filter all research outputs for work funded by a particular funder (the German Research Foundation in this example). We then do a standard query, in this case using the name of a German research vessel.

Why GraphQL

The example shows that GraphQL also supports the kinds of standard queries typically done with REST APIs. The example shows two powerful feature of GraphQL: nested queries (rather than queries only supported on the top level), and selection of the facets and fields we want to see in the results.

Use the following query in the GraphQL client at https://api.datacite.org/graphql

{
  funder(id: "https://doi.org/10.13039/501100001659") {
    id
    name
    works(query: "polarstern") {
      totalCount
      years {
        title
        count
      }
      resourceTypes {
        title
        count
      }
      nodes {
        id
        type
        titles {
          title
        }
        creators {
          id
          name
        }
        publicationYear
        publisher
      }
    }
  }
}

I took this query and put it into a jupyter notebook to show also taking results and looking at some of the data. See: https://github.com/datacite/notebooks/tree/master/pid-graph/py-find-works-by-funder

My example uses the European Commission funder ID and also looks for anything related to “Freya” by using the awardNumber as part of a custom query. Displays the related works and also the numbers by resourceType.

Hello,

I’m building a small React application w/ the graphql API that may need to make this type of queries on each page.

Currently, I’m experiencing considerable performance issues even using these examples queries.

I’m wondering if this performance is just a result of graphql and comes with the nature of using the API, or is it possible the queries (for example the one in this page) are causing these performance issues?

Response time from Chrome Developer Tools Performance shows more than 17 seconds to get the data back.

Anyone experience something similar? Is this a natural drawback to using API?

Thank you!

@Rupert_Hawtrey complex GraphQL queries will be slow, but the main issue we currently have is that the Elasticsearch queries in the backend are slower than they should be, something we hope to optimize in the coming weeks and months.

DataCite has launched a React application (using Next.js) to work with the DataCite GraphQL API. Feel free to take inspiration and/or reuse code, e.g. Apollo Client. https://github.com/datacite/akita