from strawberry.types.nodes import FragmentSpread, InlineFragment, SelectedField

_LARGE_QUERY = """query GetWorkflows {
  workflows {
    page {
      ... on Workflow {
        aliasedName: name
      }
      ... MyFragment
      name
      products {
        tag
        productBlocks {
          name
          resourceTypes {
            description
            aliasedProductBlocks: productBlocks {
              name
            }
          }
          inUseBy {
            name
          }
        }
       }
    }
  }
  workflows {
    page {
      createdAt
    }
  }
}


fragment MyFragment on Workflow {
  aliasedTarget: target
}"""

# Generated by running the above _LARGE_QUERY and logging `info.selected_fields` from the resolver
# Note: this query is a bit silly, but it hits all the edgecases I can think of

LARGE_QUERY_SELECTED_FIELDS = [
    SelectedField(
        name="workflows",
        directives={},
        arguments={},
        selections=[
            SelectedField(
                name="page",
                directives={},
                arguments={},
                selections=[
                    InlineFragment(
                        type_condition="Workflow",
                        selections=[
                            SelectedField(name="name", directives={}, arguments={}, selections=[], alias="aliasedName")
                        ],
                        directives={},
                    ),
                    FragmentSpread(
                        name="MyFragment",
                        type_condition="Workflow",
                        directives={},
                        selections=[
                            SelectedField(
                                name="target", directives={}, arguments={}, selections=[], alias="aliasedTarget"
                            )
                        ],
                    ),
                    SelectedField(name="name", directives={}, arguments={}, selections=[], alias=None),
                    SelectedField(
                        name="products",
                        directives={},
                        arguments={},
                        selections=[
                            SelectedField(name="tag", directives={}, arguments={}, selections=[], alias=None),
                            SelectedField(
                                name="productBlocks",
                                directives={},
                                arguments={},
                                selections=[
                                    SelectedField(name="name", directives={}, arguments={}, selections=[], alias=None),
                                    SelectedField(
                                        name="resourceTypes",
                                        directives={},
                                        arguments={},
                                        selections=[
                                            SelectedField(
                                                name="description",
                                                directives={},
                                                arguments={},
                                                selections=[],
                                                alias=None,
                                            ),
                                            SelectedField(
                                                name="productBlocks",
                                                directives={},
                                                arguments={},
                                                selections=[
                                                    SelectedField(
                                                        name="name",
                                                        directives={},
                                                        arguments={},
                                                        selections=[],
                                                        alias=None,
                                                    )
                                                ],
                                                alias="aliasedProductBlocks",
                                            ),
                                        ],
                                        alias=None,
                                    ),
                                    SelectedField(
                                        name="inUseBy",
                                        directives={},
                                        arguments={},
                                        selections=[
                                            SelectedField(
                                                name="name", directives={}, arguments={}, selections=[], alias=None
                                            )
                                        ],
                                        alias=None,
                                    ),
                                ],
                                alias=None,
                            ),
                        ],
                        alias=None,
                    ),
                ],
                alias=None,
            )
        ],
        alias=None,
    ),
    SelectedField(
        name="workflows",
        directives={},
        arguments={},
        selections=[
            SelectedField(
                name="page",
                directives={},
                arguments={},
                selections=[SelectedField(name="createdAt", directives={}, arguments={}, selections=[], alias=None)],
                alias=None,
            )
        ],
        alias=None,
    ),
]


SMALL_QUERY_SELECTED_FIELDS = [
    LARGE_QUERY_SELECTED_FIELDS[1],
]
