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

graphQL question: how to get all the speakers in an event #56

Closed
ttasovac opened this issue Apr 26, 2020 · 2 comments
Closed

graphQL question: how to get all the speakers in an event #56

ttasovac opened this issue Apr 26, 2020 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@ttasovac
Copy link
Collaborator

The following query gives us titles of "events" on D-C:

query myquery {
  allMdx(filter: {frontmatter: {categories: {elemMatch: {slug: {eq: "events"}}}}}) {
    nodes {
      frontmatter {
        title
      }
    }
  }
}

How can we query all the speakers in a given event? Speakers are listed in individual sessions, not the index.mdx.

Many thanks in advance.

@stefanprobst
Copy link
Collaborator

with our current flat file structure this is not super straightforward unfortunately, but you can e.g. do:

{
  speakers: allMdx(filter: {fileInfo: {sourceInstanceName: {eq: "events"}, name: {regex: "/^session/"}}}) {
    group(field: fileInfo___relativeDirectory) {
      fieldValue
      nodes {
        frontmatter {
          speakers {
            name
          }
        }
      }
    }
    distinct(field: frontmatter___speakers___name)
  }
  events: allMdx(filter: {fileInfo: {sourceInstanceName: {eq: "events"}, name: {eq: "index"}}}) {
    group(field: fileInfo___relativeDirectory) {
      fieldValue
      nodes {
        frontmatter {
          title
        }
      }
    }
  }
}

we could either hide this in a custom resolver (so you could just query with query { eventSpeakers(id: "some-event-id") { name } or adjust our data model to make EventSession a child node of Event (but i'd not want to do this before adding the CMS stuff)

@ttasovac ttasovac added the question Further information is requested label Apr 28, 2020
@ttasovac
Copy link
Collaborator Author

Thanks a lot! This should do it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants