fragment BaseMediaItem on MediaItem {
  srcSet
  altText
  sourceUrl
}

query MediaItemsMany {
  mediaItems(first: 100, where: { status: PUBLISH }) {
    nodes {
      ...BaseMediaItem
    }
  }
}

query MediaItemsOne($slug: ID!) {
  mediaItem(id: $slug, idType: URI) {
    ...BaseMediaItem
  }
}

fragment BasePage on Page {
  id
  slug
  title
  content
  status
}

query PagesMany {
  pages(first: 100, where: { status: PUBLISH }) {
    nodes {
      ...BasePage
    }
  }
}

query PagesOne($slug: ID!) {
  page(id: $slug, idType: URI) {
    ...BasePage
  }
}

fragment BaseWork on Work {
  id
  slug
  title
  content
  status
  work {
    date
    image {
      ...BaseMediaItem
    }
    link
    role
  }
}

query WorksMany {
  works(first: 100, where: { status: PUBLISH }) {
    nodes {
      ...BaseWork
    }
  }
}

query WorksOne($slug: ID!) {
  work(id: $slug, idType: URI) {
    ...BaseWork
  }
}

fragment BaseProject on Project {
  id
  slug
  title
  content
  status
  project {
    date
    link
    description
  }
}

query ProjectsMany {
  projects(first: 100, where: { status: PUBLISH }) {
    nodes {
      ...BaseProject
    }
  }
}

query ProjectsOne($slug: ID!) {
  project(id: $slug, idType: URI) {
    ...BaseProject
  }
}

fragment BasePost on Post {
  id
  slug
  title
  content
  status
  date
  modified
  tags {
    nodes {
      ...BaseTag
    }
  }
  post {
    featured {
      ...BaseMediaItem
    }
  }
}

query PostsMany {
  posts(first: 100, where: { status: PUBLISH }) {
    nodes {
      ...BasePost
    }
  }
}

query PostsOne($slug: ID!) {
  post(id: $slug, idType: URI) {
    ...BasePost
  }
}

query PostsManyByTag($tag: String!) {
  posts(first: 100, where: { status: PUBLISH, tag: $tag }) {
    nodes {
      ...BasePost
    }
  }
}

query Search {
  posts(first: 100) {
    nodes {
      ...BasePost
    }
  }
  projects(first: 100) {
    nodes {
      ...BaseProject
    }
  }
  works(first: 100) {
    nodes {
      ...BaseWork
    }
  }
}

fragment BaseTag on Tag {
  id
  slug
  name
  count
}

query TagsMany {
  tags(first: 100) {
    nodes {
      ...BaseTag
    }
  }
}
