Create Project
Input attributes
When you want to create a project inside your budget component, you need to rely on the ProjectAttributes type, which has the following input fields:
• address (Optional) - String
• budget_amount (Optional) - Integer
• description (Optional) - JSON
• latitude (Optional) - Float
• longitude (Optional) - Float
• proposal_ids (Optional) - Proposal ids to assign to this project
• title (Required) - JSON
• taxonomies (Optional) - Taxonomy ids to assign to this project
Sample request
The CreateProject mutation allows authenticated administrators to create new projects within a budget in a Decidim budget component. This mutation uses the existing CreateProject command from the admin controller.
mutation createProject($componentId: ID!, $budgetId: ID!, $input: CreateProjectInput!){
component(id: $componentId){
... on BudgetsMutation {
budget(id: $budgetId){
createProject(input: $input){
id
url
}
}
}
}
}
Example of submitted variables
{
"componentId": "3",
"budgetId": "5",
"input": {
"attributes": {
"budgetAmount": 12300,
"address": "FOOBAR",
"latitude": 123.00,
"longitude": 12.33,
"proposalIds": [1,2,3],
"taxonomies": [1,2,3],
"description": {
"en": "Project description created from component"
},
"title": {
"en": "Project title created from component"
}
}
}
}
Error Handling
The most frequent errors that can be generated by this mutation are as follows:
Caveats
Sometimes, you may get a server response like:
{
"errors": [
{
"message": [],
"locations": [
{
"line": 5,
"column": 8
}
],
"path": [
"component",
"budget",
"createProject"
],
"extensions": {
"code": "ATTRIBUTE_VALIDATION_ERROR"
}
}
],
"data": {
"component": {
"budget": {
"createProject": null
}
}
}
}
To fix this, please check your taxonomy parameters.