Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor navigation and shelf into single query #291

Closed
2 of 5 tasks
hutchgrant opened this issue Feb 20, 2020 · 1 comment · Fixed by #295
Closed
2 of 5 tasks

refactor navigation and shelf into single query #291

hutchgrant opened this issue Feb 20, 2020 · 1 comment · Fixed by #295
Assignees
Labels
CLI Content as Data documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) v0.5.0 Data w/ GraphQL

Comments

@hutchgrant
Copy link
Member

hutchgrant commented Feb 20, 2020

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

As per #285, I would like to suggest we refactor navigation and shelf into a single Menu query through graphql as described here

Details

schema

  type Link {
    label: String,
    link: String
  }

  type Menu {
    item: Link
    children: [Menu]
  }

  enum MenuOrderBy {
    label_asc,
    label_desc
    index_asc,
    index_desc
  }

  type Query {
    menu(filter: String, orderBy: MenuOrderBy): Menu
  }

our query from our components(both header and shelf):

query($menu: String!,  $order: String) {
  menu(filter: $menu, orderBy: $order) {
    item {
      label,
      link
    }
    children {
      item {
        label,
        link
      },
      children {
        item {
          label,
          link
        }
      }
    }
  }
}

This will work for both navigation, side menus, footers, etc. We can filter by menu type and sort the menus as well.

@thescientist13
Copy link
Member

Yeah, this could make a lot of sense, since really the only difference between Navigation and Children queries is that Navigation is just "capped" at a depth of 1. Same could be achieved through one query as you suggest.

I think this would solve part of #273. Not everywhere I don't think since there are various usages of [0] but certainly for queries it would.

@thescientist13 thescientist13 added the enhancement Improve something existing (e.g. no docs, new APIs, etc) label Feb 21, 2020
@thescientist13 thescientist13 added Content as Data documentation Greenwood specific docs website Tasks related to the projects website / documentation CLI v0.5.0 Data w/ GraphQL and removed website Tasks related to the projects website / documentation labels Apr 16, 2020
@thescientist13 thescientist13 mentioned this issue Apr 22, 2020
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Content as Data documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) v0.5.0 Data w/ GraphQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants