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

GQL operation string is missing fragment used in a query #202

Closed
jakub-bacic opened this issue Sep 1, 2023 · 0 comments · Fixed by #203
Closed

GQL operation string is missing fragment used in a query #202

jakub-bacic opened this issue Sep 1, 2023 · 0 comments · Fixed by #203

Comments

@jakub-bacic
Copy link
Contributor

For the given GQL schema:

type ItemA {
  valueA: String
}

type ItemB {
  valueB: String
}

union Item = ItemA | ItemB

type Container {
  name: String
  items: [Item]
}

type Query {
  container(id: ID!): Container
}

and following query:

fragment ItemAFragment on ItemA {
  valueA
}

fragment ItemBFragment on ItemB {
  valueB
}

fragment ItemFragment on Item {
  ... on ItemA {
    ...ItemAFragment
  }
  ... on ItemB {
    ...ItemBFragment
  }
}

fragment ContainerFragment on Container {
  name
  items {
    ...ItemFragment
  }
}

query getContainer($id: ID!) {
  container(id: $id) {
    ...ContainerFragment  
  }
}

the generated client contains the following get_container method:

...
    async def get_container(self, id: str) -> GetContainer:
        query = gql(
            """
            query getContainer($id: ID!) {
              container(id: $id) {
                ...ContainerFragment
              }
            }

            fragment ContainerFragment on Container {
              name
              items {
                ...ItemFragment
              }
            }

            fragment ItemFragment on Item {
              ... on ItemA {
                ...ItemAFragment
              }
              ... on ItemB {
                ...ItemBFragment
              }
            }
            """
        )
...

Operation string is missing ItemAFragment and ItemBFragment definitions, even though they are used in ItemFragment.

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

Successfully merging a pull request may close this issue.

1 participant