Skip to content

Commit

Permalink
Merge pull request #624 from thoth-pub/feature/574_complete_schema
Browse files Browse the repository at this point in the history
Add descriptions for all remaining fields/queries in GraphQL schema (#574)
  • Loading branch information
rhigman authored Sep 4, 2024
2 parents 0c5a7c1 + 126fcc3 commit 5e73182
Show file tree
Hide file tree
Showing 21 changed files with 2,139 additions and 137 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- [574](https://github.com/thoth-pub/thoth/issues/574) - Add descriptions to all remaining items in schema

### Fixed
- [548](https://github.com/thoth-pub/thoth/issues/548) - Prevent users from deleting contributors/institutions which are linked to works by other publishers

Expand Down
625 changes: 536 additions & 89 deletions thoth-api/src/graphql/model.rs

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions thoth-api/src/graphql/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ use serde::Deserialize;
use serde::Serialize;

#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, juniper::GraphQLEnum)]
#[graphql(description = "Order in which to sort query results (ascending or descending)")]
#[graphql(description = "Order in which to sort query results")]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Direction {
#[cfg_attr(feature = "backend", graphql(description = "Ascending order"))]
#[default]
Asc,
#[cfg_attr(feature = "backend", graphql(description = "Descending order"))]
Desc,
}

Expand All @@ -17,13 +19,23 @@ fn test_direction_default() {
}

#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, juniper::GraphQLEnum)]
#[graphql(
description = "Expression to use when filtering by numeric value (greater than or less than)"
)]
#[graphql(description = "Expression to use when filtering by numeric value")]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Expression {
#[cfg_attr(
feature = "backend",
graphql(
description = "Return only results with values which are greater than the value supplied"
)
)]
#[default]
GreaterThan,
#[cfg_attr(
feature = "backend",
graphql(
description = "Return only results with values which are less than the value supplied"
)
)]
LessThan,
}

Expand Down
2 changes: 2 additions & 0 deletions thoth-api/src/model/affiliation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct AffiliationWithContribution {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, Insertable),
graphql(description = "Set of values required to define a new association between a person and an institution for a specific contribution"),
diesel(table_name = affiliation)
)]
pub struct NewAffiliation {
Expand All @@ -70,6 +71,7 @@ pub struct NewAffiliation {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, AsChangeset),
graphql(description = "Set of values required to update an existing association between a person and an institution for a specific contribution"),
diesel(table_name = affiliation, treat_none_as_null = true)
)]
pub struct PatchAffiliation {
Expand Down
2 changes: 2 additions & 0 deletions thoth-api/src/model/contribution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ pub struct ContributionWithWork {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, Insertable),
graphql(description = "Set of values required to define a new individual involvement in the production of a work"),
diesel(table_name = contribution)
)]
pub struct NewContribution {
Expand All @@ -170,6 +171,7 @@ pub struct NewContribution {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, AsChangeset),
graphql(description = "Set of values required to update an individual involvement in the production of a work"),
diesel(table_name = contribution, treat_none_as_null = true)
)]
pub struct PatchContribution {
Expand Down
2 changes: 2 additions & 0 deletions thoth-api/src/model/contributor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct Contributor {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, Insertable),
graphql(description = "Set of values required to define a new individual involved in the production of works"),
diesel(table_name = contributor)
)]
pub struct NewContributor {
Expand All @@ -65,6 +66,7 @@ pub struct NewContributor {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, AsChangeset),
graphql(description = "Set of values required to update an existing individual involved in the production of works"),
diesel(table_name = contributor, treat_none_as_null = true)
)]
pub struct PatchContributor {
Expand Down
2 changes: 2 additions & 0 deletions thoth-api/src/model/funding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub struct FundingWithWork {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, Insertable),
graphql(description = "Set of values required to define a new grant awarded for the publication of a work by an institution"),
diesel(table_name = funding)
)]
pub struct NewFunding {
Expand All @@ -81,6 +82,7 @@ pub struct NewFunding {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, AsChangeset),
graphql(description = "Set of values required to update an existing grant awarded for the publication of a work by an institution"),
diesel(table_name = funding, treat_none_as_null = true)
)]
pub struct PatchFunding {
Expand Down
2 changes: 2 additions & 0 deletions thoth-api/src/model/imprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub struct ImprintWithPublisher {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, Insertable),
graphql(description = "Set of values required to define a new brand under which a publisher issues works"),
diesel(table_name = imprint)
)]
pub struct NewImprint {
Expand All @@ -73,6 +74,7 @@ pub struct NewImprint {
#[cfg_attr(
feature = "backend",
derive(juniper::GraphQLInputObject, AsChangeset),
graphql(description = "Set of values required to update an existing brand under which a publisher issues works"),
diesel(table_name = imprint, treat_none_as_null = true)
)]
pub struct PatchImprint {
Expand Down
Loading

0 comments on commit 5e73182

Please sign in to comment.