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

Optional lists? optional().list.optional() #198

Open
tzdesign opened this issue Feb 12, 2024 · 0 comments
Open

Optional lists? optional().list.optional() #198

tzdesign opened this issue Feb 12, 2024 · 0 comments

Comments

@tzdesign
Copy link

Describe the bug
I'm not sure if it's a bug or I just don't get the types yet.

I have a shop with optional categories and a M2M relation.

extension Objects.ShopFairShop {
 public static func categories<T>(
    filter: OptionalArgument<InputObjects.ShopFairShopShopFairCategoryFilter> = .init(),
    sort: OptionalArgument<[OptionalArgument<String>]> = .init(),
    limit: OptionalArgument<Int> = .init(), offset: OptionalArgument<Int> = .init(),
    page: OptionalArgument<Int> = .init(), search: OptionalArgument<String> = .init(),
    selection: Selection<T, [Objects.ShopFairShopShopFairCategory?]?>
  ) -> Selection<T, Objects.ShopFairShop> {
    Selection<T, Objects.ShopFairShop> {
      try $0.categories(
        filter: filter, sort: sort, limit: limit, offset: offset, page: page, search: search,
        selection: selection)
    }
  }
}

At least I get to this:

let categorySelection = Selection.ShopFairShopShopFairCategory{
            try $0.shopFairCategoryId(selection: Selection.ShopFairCategory{ try $0.name() ?? "" }.optional())
        }.optional().list

But I need to get the list optional as well. Don't know how.

If I do this:

let categorySelection = Selection.ShopFairShopShopFairCategory{
            try $0.shopFairCategoryId(selection: Selection.ShopFairCategory{ try $0.name() ?? "" }.optional())
        }.optional().list.optional()

It gives me:

Generic parameter 'UnwrappedT' could not be inferred

To Reproduce

My graph is not public yet, so It's hard to give a repo

Expected behavior
My expectation was, that list.optional would give me:

Selection<[String?], [Objects.ShopFairShopShopFairCategory?]?>
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

No branches or pull requests

1 participant