-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from uxpolishop/feature/reviews
feature/reviews
- Loading branch information
Showing
7 changed files
with
88 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
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] | ||
|
||
### Changed | ||
- Renamed `review` query to `rating`. | ||
- Renamed `reviews` query to `ratings`. | ||
|
||
### Added | ||
- New query `reviews`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,57 @@ | ||
|
||
type Element { | ||
type RatingElement { | ||
ProductId: Int, | ||
TotalRatings: Int, | ||
Rating: Float, | ||
} | ||
|
||
type Review { | ||
type Rating { | ||
HasErrors: Boolean, | ||
Element: [Element], | ||
Element: [RatingElement], | ||
ErrorList: [String], | ||
Total: Int, | ||
CurrentPage: Int | ||
} | ||
|
||
type Fields { | ||
Name: String, | ||
Values: [String] | ||
} | ||
|
||
type User { | ||
Name: String, | ||
Email: String, | ||
CPF: String, | ||
City: String, | ||
State: String, | ||
UserId: String, | ||
ExhibitionName: String, | ||
} | ||
|
||
type ReviewElement { | ||
ReviewId: Int, | ||
Rating: Int, | ||
Review: String, | ||
Date: String, | ||
Likes: Int, | ||
Dislikes: Int, | ||
CustomFields: [Fields], | ||
User: User, | ||
ReferenceOrder: String, | ||
ReviewTitle: String, | ||
BoughtProduct: Boolean | ||
} | ||
|
||
type Reviews { | ||
HasErrors: Boolean, | ||
Element: [ReviewElement], | ||
ErrorList: [String], | ||
Total: Int, | ||
CurrentPage: Int | ||
} | ||
|
||
type Query { | ||
review(productId: String): Review @withSecretKeys | ||
reviews(productIds: [String!]): Review @withSecretKeys | ||
rating(productId: String): Rating @withSecretKeys | ||
ratings(productIds: [String!]): Rating @withSecretKeys | ||
reviews(productId: String): Reviews @withSecretKeys | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { | ||
review, | ||
rating, | ||
ratings, | ||
reviews, | ||
} from './yourviewsResolver' | ||
|
||
export const queries = { | ||
review, | ||
rating, | ||
ratings, | ||
reviews, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
interface ReviewArgs { | ||
interface SingleProductArgs { | ||
productId: string | ||
} | ||
|
||
export const review = async (_: any, args: ReviewArgs, ctx: Context) => { | ||
const data = await ctx.clients.yourviews.getReview(args.productId) | ||
console.log('data', data) | ||
export const rating = async (_: any, args: SingleProductArgs, ctx: Context) => { | ||
const data = await ctx.clients.yourviews.getRating(args.productId) | ||
return data | ||
} | ||
|
||
interface ReviewsArgs { | ||
interface MultipleProductsArg { | ||
productIds: string[] | ||
} | ||
|
||
export const reviews = async (_: any, args: ReviewsArgs, ctx: Context) => { | ||
const data = await ctx.clients.yourviews.getReviews(args.productIds) | ||
export const ratings = async (_: any, args: MultipleProductsArg, ctx: Context) => { | ||
const data = await ctx.clients.yourviews.getRatings(args.productIds) | ||
return data | ||
} | ||
|
||
export const reviews = async (_: any, args: SingleProductArgs, ctx: Context) => { | ||
const data = await ctx.clients.yourviews.getReviews(args.productId) | ||
return data | ||
} |