GraphQLSwift / Graphiti

The Swift GraphQL Schema framework for macOS and Linux
MIT License
532 stars 67 forks source link

PartialSchema error with argument in type field #111

Closed ZirgVoice closed 1 year ago

ZirgVoice commented 1 year ago

I have a type that has a field that takes an argument. The problem is that when I add arguments to such a field, the scheme does not work. When running npx diagnose-endpoint it writes "Unknown kind of type: AddressFilter". The filtering argument has the type AddressFilter, which is lobbed into the scheme. At the same time AddressFilter is also in query and there it works Example of type:

        Type(CountryModel.self, as: "Country") {
            Field("id", at: \.gID)
            Field("code", at: \.code)
            Field("name", at: \.name)
            Field("fullName", at: \.fullName)
            Field("iso3", at: \.iso3)
            Field("isoNumber", at: \.isoNumber)
            Field("continent", at: CountryModel.getContinent, as: TypeReference<ContinentModel>.self)
            Field("addressMany", at: CountryModel.getAddressMany, as: [TypeReference<AddressModel>].self) {
                Argument("filtering", at: \.filtering)
            }
            Field("createdAt", at: \.createdAt)
            Field("updatedAt", at: \.updatedAt)
        }

If I don't use PartialSchema and write the whole thing in one file, it works

cshadek commented 1 year ago

@ZirgVoice how are you defining AddressFilter in the schema? Is it an input type?

Also, are you declaring AddressFilter before or after Country? Does it work if you change the order?

ZirgVoice commented 1 year ago

Yes AddressFilter is declared as input type and in SchemaBuilder it is declared before Country. I tried to declare it after Country but it doesn't help, and in PartialSchema the order shouldn't matter.

cshadek commented 1 year ago

@ZirgVoice I just tried multiple times to reproduce your issue, but I was unable to. Are you using the latest release?

Can you provide more information about how you're declaring AddressFilter in the schema.

ZirgVoice commented 1 year ago

Yes, I am using the latest release This is how AddressFilter is declared

        Input(AddressFilter.self) {
            InputField("addressILIKE", at: \.addressILIKE)
                .description("Inaccurate search by address")
            InputField("zipCodeEQ", at: \.zipCodeEQ)
                .description("Equal to zipCode")
            InputField("zipCodeNEQ", at: \.zipCodeNEQ)
                .description("Not equal to zipCode")
            InputField("cityEQ", at: \.cityEQ)
                .description("Equal to city")
            InputField("cityNEQ", at: \.cityNEQ)
                .description("Not equal to city")
            InputField("longitudeEQ", at: \.longitudeEQ)
                .description("Equal to longitude")
            InputField("longitudeNEQ", at: \.longitudeNEQ)
                .description("Not equal to longitude")
            InputField("longitudeGT", at: \.longitudeGT)
                .description("Great than longitude")
            InputField("longitudeGTE", at: \.longitudeGTE)
                .description("Great or equal than longitude")
            InputField("longitudeLT", at: \.longitudeLT)
                .description("Less than longitude")
            InputField("longitudeLTE", at: \.longitudeLTE)
                .description("Less or equal than longitude")
            InputField("latitudeEQ", at: \.latitudeEQ)
                .description("Equal to latitude")
            InputField("latitudeNEQ", at: \.latitudeNEQ)
                .description("Not equal to latitude")
            InputField("latitudeGT", at: \.latitudeGT)
                .description("Great than latitude")
            InputField("latitudeGTE", at: \.latitudeGTE)
                .description("Great or equal than latitude")
            InputField("latitudeLT", at: \.latitudeLT)
                .description("Less than latitude")
            InputField("latitudeLTE", at: \.latitudeLTE)
                .description("Less or equal than latitude")
            InputField("countryIDEQ", at: \.gCountryIDEQ)
                .description("Equal to countryID")
            InputField("countryIDNEQ", at: \.gCountryIDNEQ)
                .description("Not equal to countryID")
        }
ZirgVoice commented 1 year ago

It all worked, restarting xcode helped. Sorry for the inconvenience (: