GraphQL: How to filter by publication year

I need to find all data publications of a certain institution and of a certain publication year. The DataCite support was kind enough to provide me with some GraphQL magic for the institution. I tried to extend that so that it also filters one year but I failed. What I have is:

query ($numWorks: Int, $cursor: String, $year: Int) {
  organization(id: "xxxxxxx") {
    id
    name
    […]
    works(
      first: $numWorks
      after: $cursor
    ) {
      ...WorkConnectionFragment
      nodes {
        ...WorkFragment
        __typename
      }
      __typename
    }
    __typename
  }
}
fragment WorkConnectionFragment on WorkConnectionWithTotal {
  […]
}
fragment WorkFragment on Work {
  id
  doi
  […]
  publicationYear
  […]
}

Where do I attach the $year variable to and how?

Hi @bronger - you can filter the works by publication year like this:

 works(
      first: $numWorks
      after: $cursor
      published: "2022" 
    )

Let me know if that doesn’t work!

1 Like

Thank you, this worked!b

1 Like