Skip to content

Instantly share code, notes, and snippets.

@github-francisco-pereira
Created August 10, 2019 18:05
Show Gist options
  • Select an option

  • Save github-francisco-pereira/3c97a6e40267ecbba3a4efded419d8b3 to your computer and use it in GitHub Desktop.

Select an option

Save github-francisco-pereira/3c97a6e40267ecbba3a4efded419d8b3 to your computer and use it in GitHub Desktop.
const {
GraphQLString,
GraphQLObjectType,
GraphQLBoolean,
GraphQLList,
} = require('graphql');
const ListingErrorResponseType = require('app/types/listing_error');
module.exports = new GraphQLObjectType({
name: 'ListingActionResponseType',
description: 'Response about some action that you do, like activate or change the publication type',
fields: {
message: {
type: GraphQLString,
description: 'Only for compatibility',
deprecationReason: 'Listing actions response needs to be more complex than a single message',
resolve({ data }) {
return data.message;
},
},
success: {
type: GraphQLBoolean,
description: 'Indicates if have success',
resolve({ data }) {
return data.success;
},
},
errors: {
type: new GraphQLList(ListingErrorResponseType),
description: 'List of errors',
resolve({ data }) {
return data.errors;
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment