Querying proposal data through the GraphQL API
- 1 Documentation
- 2 Get all proposals in a call
- 3 Get the questions of a proposal
- 4 Get the title and abstract of a proposal
- 5 Get the generic template answers and samples of a proposal
- 6 Example query to get proposals and all of their questions from a call
- 7 Downloading proposal pdf documents using API token
Documentation
For generated documentation on what objects and fields are available, you can access the GraphQL Docs
tab in the GraphQL Playground, either locally (http://localhost:8081/graphql) or on dev (https://devproposal.facilities.rl.ac.uk/graphql).
Get all proposals in a call
Pass in a filter to the proposals query.
{
proposals(filter: { callId: 1}) {
proposals { # Proposal[]
status
}
}
}
Get the questions of a proposal
From the questionary of a proposal, you can get a list of answers for each step (topic).
Note that while the proposal basis (title and abstract), sample, and sub template (generic template) questions are included in this list, their answers are not accessible through the value.
{
proposal(primaryKey: 1) {
questionary {
steps {
fields { # Answer[]
question {
question # The question title
id
naturalKey
dataType
}
value # The answer for most question types
}
}
}
}
}
Get the title and abstract of a proposal
The title and abstract answers aren't accessible through the questionary of a proposal, so query them on a proposal.
{
proposal(primaryKey: 1) {
title
abstract
}
}
Get the generic template answers and samples of a proposal
You can look at the generic templates or sample fields of a proposal, and then get the question data from the questionary.
Note that this will show all generic templates and samples within the proposal (i.e. answers to potentially more than one question). If you use this in combination with Get the questions of a proposal, you can cross reference the naturalKey or id.
{
proposal(primaryKey: 43) {
samples {
questionary {
steps {
fields {
question {
question # The question
id
naturalKey
}
value # The answer
}
}
}
}
genericTemplates {
questionary {
steps {
fields {
question {
question # The question
id
naturalKey
}
value # The answer
}
}
}
}
}
}
Example query to get proposals and all of their questions from a call
{
proposals(filter: { callId: 1}) {
proposals {
title
abstract
questionary { # Only includes a reference to sample, proposal basis and sub template answers
steps {
fields {
question {
question # The question
}
value # The answer
}
}
}
genericTemplates {
questionary {
steps {
fields {
question {
id
naturalKey
question # The question
}
value # The answer
}
}
}
}
samples {
questionary {
steps {
fields {
question {
id
naturalKey
question # The question
}
value # The answer
}
}
}
}
}
}
}
Downloading proposal pdf documents using API token
To download pdfs using primary key or proposal ids you will need to create a token with FactoryServices.getPdfProposals
permission. Proposals can be downloaded with primary key by requesting /download/pdf/proposal/<primary key>
or /download/pdf/proposal/<primary key>,<primary key>
for multiple proposals in a single file. To download using ids(RB numbers) send request to /download/pdf/proposal/<id(RB number)>?filter=id
or /download/pdf/proposal/<id(RB number)>,<id(RB number)>?filter=id
for multiple proposals in a single file.