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

Generated code for Query which has an output and a query with the same name is not compiling. #2988

Closed
rajshekhar16 opened this issue May 2, 2023 · 2 comments
Labels
awaiting response bug Generally incorrect behavior

Comments

@rajshekhar16
Copy link

rajshekhar16 commented May 2, 2023

Summary

I came across an issue while using 'The Codegen CLI' to generate code. When I tried to compile the code for a query named for say "asset", which had an output property with the same name "asset", the compilation failed. It seems that having a query and an output property with the same name caused a conflict in the generated code, resulting in compilation errors.

Version

1.1.2

Steps to reproduce the behavior

Generating swift code using moduleType: .swiftPackageManager for this query:

query GetAsset($groupedAssetId: ID!, $filter: DataCategoryEnum, $addressesFilter2: AddressTypeEnum) {
  asset(groupedAssetId: $groupedAssetId) {
    ... on GroupedAssetOutput {
      asset {
        artifactsV2(filter: $filter) {
          contents {
            addresses(filter: $addressesFilter2) {
              contents {
                ... on AddressHspcOutput {
                  endpoint
                }
              }
            }
          }
        }
      }
    }
  }
}

In above you can clearly see I have query asset and output on GroupedAssetOutput has also asset

Above query will generate this swift code:

public struct Asset: OrcaApi.SelectionSet {
    ...
    public var asGroupedAssetOutput: AsGroupedAssetOutput? { _asInlineFragment() }
    ...
    public struct AsGroupedAssetOutput: OrcaApi.InlineFragment {
        ...
        public var asset: Asset { __data["asset"] }
        ...
        public struct Asset: OrcaApi.SelectionSet {
            ...
            public var artifactsV2: ArtifactsV2? { __data["artifactsV2"] }
            ...
            public struct ArtifactsV2: OrcaApi.SelectionSet {
                ...
                public var contents: [Content] { __data["contents"] }
                ...
                public struct Content: OrcaApi.SelectionSet {
                    ...
                    public var addresses: Addresses { __data["addresses"] }
                    ...
                    public struct Addresses: OrcaApi.SelectionSet {
                        ...
                        public var contents: [Content] { __data["contents"] }
                        ...
                        public struct Content: OrcaApi.SelectionSet {
                            ...
                            public var asAddressHspcOutput: AsAddressHspcOutput? { _asInlineFragment() }
                            ...
                            public struct AsAddressHspcOutput: OrcaApi.InlineFragment {
                                ...
                                public typealias RootEntityType = Asset.AsGroupedAssetOutput.Asset.ArtifactsV2.Content.Addresses.Content
                                ...
                            }
                        }
                    }
                }
            }
        }
    }
}

I am getting an error on public typealias RootEntityType = ... . Error is
"Type ''AsGroupedAssetOutput' is not a member type of struct ProjectName.ProjectNameApi.GetAssetQuery.Data.Asset.AsGroupedAssetOutput.Asset''

@rajshekhar16 rajshekhar16 added bug Generally incorrect behavior needs investigation labels May 2, 2023
@AnthonyMDev
Copy link
Contributor

This may actually be resolved in the 1.1.3 patch release that came out yesterday by #2956! Please update to the new patch version and confirm if this is still an issue for us.

@rajshekhar16
Copy link
Author

It's working fine in 1.1.3. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response bug Generally incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants