def get_gql_query(settings: str, affil: str = "OWNER") -> str:
    """Construct GraphQL query from settings list.

    Args:
        settings (str): Names of repo settings according to the GraphQL API,
            separated by new lines. Use '\n'.join(settings_list).
        affil (str, optional): Comma-separated string of author affiliations to their
            repos. One or several of OWNER, COLLABORATOR, ORGANIZATION_MEMBER.
            Defaults to "OWNER".

    Returns:
        str: GraphQL query.
    """
    return """{
      viewer {
        repositories(first: 100, affiliations: [{affil}]) {
          nodes {
            name
            nameWithOwner
            isArchived
            isFork
            {settings}
          }
        }
        organizations(first: 100) {
          nodes {
            login
            repositories(first: 100) {
              nodes {
                name
                nameWithOwner
                isArchived
                isFork
                {settings}
              }
            }
          }
        }
      }
    }""".replace(
        "{settings}", settings
    ).replace(
        "{affil}", affil
    )