#import "~/packages_and_registries/package_registry/graphql/fragments/package_data.fragment.graphql"
#import "~/packages_and_registries/package_registry/graphql/fragments/package_group_settings.fragment.graphql"
#import "~/graphql_shared/fragments/page_info.fragment.graphql"

query getPackages(
  $fullPath: ID!
  $isGroupPage: Boolean!
  $sort: PackageSort
  $groupSort: PackageGroupSort
  $packageName: String
  $packageType: PackageTypeEnum
  $first: Int
  $last: Int
  $after: String
  $before: String
) {
  project(fullPath: $fullPath) @skip(if: $isGroupPage) {
    id
    packages(
      sort: $sort
      packageName: $packageName
      packageType: $packageType
      after: $after
      before: $before
      first: $first
      last: $last
    ) {
      count
      nodes {
        ...PackageData
      }
      pageInfo {
        ...PageInfo
      }
    }
    group {
      ...GroupPackageSettings
    }
  }
  group(fullPath: $fullPath) @include(if: $isGroupPage) {
    id
    packages(
      sort: $groupSort
      packageName: $packageName
      packageType: $packageType
      after: $after
      before: $before
      first: $first
      last: $last
    ) {
      count
      nodes {
        ...PackageData
      }
      pageInfo {
        ...PageInfo
      }
    }
    ...GroupPackageSettings
  }
}
