reactioncommerce / reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
https://mailchimp.com/developer/open-commerce/
GNU General Public License v3.0
12.34k stars 2.17k forks source link

Create a tags query in GraphQL #4104

Closed spencern closed 6 years ago

spencern commented 6 years ago

Summary Create a query to retreive tags associated with navigation in GraphQL for the provided shop.

Implementation

Schema

type Tag implements Node, Deletable {
  _id: ID!
  name: String!
  slug: String
  # type: String # OMIT: Introduced for Foray?
  metafields: [Metafield]
  position: Int
  relatedTags: [TagConnection]
  isDeleted: Boolean!
  isTopLevel: Boolean!
  #isVisible: Boolean! # OMIT: This is not editable or used. Keep in db but don't expose over Graphql.
  #groups: [String] # OMIT: Not used in core. Limits visibility to groups.
  shop: Shop!
  createdAt: DateTime!
  updatedAt: DateTime!
}

enum TagSortByField {
  _id
  name
  createdAt
  updatedAt
}

type TagEdge implements NodeEdge {
  cursor: ConnectionCursor!
  node: Tag
}

type TagConnection implements NodeConnection {
  edges: [TagEdge]
  nodes: [Tag]
  pageInfo: PageInfo!
  totalCount: Int!
}

Query

The root navigationTags query should have the following signature

# Returns a paged list of tags for a shop
tags(shopId: ID!, isTopLevel: Boolean, sortOrder: SortOrder = asc, sortBy: TagSortByField = createdAt): TagConnection

Also create a similar query within the Shop type

# Returns a paged list of tags for this shop
tags(isTopLevel: Boolean, sortOrder: SortOrder = asc, sortBy: TagSortByField = createdAt): TagConnection

Both queries return a TagConnection filtered by the arguments provided.

You'll need to implement Tag.relatedTags as a separate resolver. Figure out a way to throw an error if more than 1 level of relatedTags is requested.

Acceptance Criteria

nnnnat commented 6 years ago

Issue moved to reactioncommerce/reaction-next-starterkit #5 via ZenHub