graphbrainz/src/types/rating.js
Brian Beck f095cd4de7
Modernize dependencies, syntax, imports (#93)
* wip: Modernize dependencies, syntax, imports

* Use final release of ava-nock v2

* Update Travis config

* Remove Node 13 from test matrix

* Replace errorClass with parseErrorMessage in subclasses

* define exports, apply updated lint rules

* Remove markdown eslint plugin

* Update README

* v9.0.0-beta.1

* Add gql tag to exports

* v9.0.0-beta.2

* Bump ava-nock, add test

* Update dataloader loadMany usage

* Add modules note to README

* Add retry option to got calls
2021-04-15 21:34:29 -07:00

29 lines
1,003 B
JavaScript

import GraphQL from 'graphql';
import { createSubqueryResolver } from '../resolvers.js';
const { GraphQLObjectType, GraphQLNonNull, GraphQLInt, GraphQLFloat } = GraphQL;
export const Rating = new GraphQLObjectType({
name: 'Rating',
description: `[Ratings](https://musicbrainz.org/doc/Rating_System) allow users
to rate MusicBrainz entities. User may assign a value between 1 and 5; these
values are then aggregated by the server to compute an average community rating
for the entity.`,
fields: () => ({
voteCount: {
type: new GraphQLNonNull(GraphQLInt),
description: 'The number of votes that have contributed to the rating.',
resolve: (rating) => rating['votes-count'],
},
value: {
type: GraphQLFloat,
description: 'The average rating value based on the aggregated votes.',
},
}),
});
export const rating = {
type: Rating,
description: 'The rating users have given to this entity.',
resolve: createSubqueryResolver({ inc: 'ratings' }),
};