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

Renaming ConnectionTypes isn't working #106

Closed
cshadek opened this issue Mar 6, 2023 · 6 comments
Closed

Renaming ConnectionTypes isn't working #106

cshadek opened this issue Mar 6, 2023 · 6 comments

Comments

@cshadek
Copy link
Contributor

cshadek commented Mar 6, 2023

Renaming connection types, doesn't seem to fully work.

Type(ChatObject.self, as: "Chat") {
    Field("messages", at: ChatObject.messages, as: Connection<MessageObject>.self) {
                    Argument("first", at: \.first)
                    Argument("after", at: \.after)
                    Argument("last", at: \.last)
                    Argument("before", at: \.before)
    }
}

Type(MessageObject.self, as: "Message") {
    Field("id", at: \.id)
    Field("text", at: \.text)
}

ConnectionType(MessageObject.self, as: "Message")

I get the following error:
Fatal error: 'try!' expression unexpectedly raised an error: Type "MessageObjectConnection" was referenced but not defined.

When I don't rename the ConnectionType, then the schema builds, but I end up with MessageObjectConnection instead of MessageConnection.

If I don't include the Chat type, then the schema builds with the correct MessageConnection name.

@cshadek
Copy link
Contributor Author

cshadek commented Mar 8, 2023

@d-exclaimation do you have an idea of how to fix this?

@d-exclaimation
Copy link
Member

d-exclaimation commented Mar 8, 2023

Not 100% sure what's the issue is caused by. My guess is probably the fact the Message Object Connection is referenced in Chat type and renaming it somehow breaks that. I haven't used it personally in a while but I can take a look at it

@cshadek
Copy link
Contributor Author

cshadek commented Mar 8, 2023

While on this topic, there's probably some sense in rethinking the Connection API sometime.

Some nice improvements would be:

  • Allowing connections of protocols or unions
  • Allowing custom fields on connections
  • Allowing custom fields on edges

These improvements would arguably make the Connection feature that much more powerful.

I have a bit of an idea of how this could be done, but my understanding is that there are issues around how to make this work with Codable.

@cshadek
Copy link
Contributor Author

cshadek commented Mar 8, 2023

@d-exclaimation the renaming issue is obviously more pressing (though it's still not the end of the world), but I thought you may have some ideas on everything else too.

And there's always the ability to just create your own custom connections, and that solves all these problems

@cshadek
Copy link
Contributor Author

cshadek commented Mar 13, 2023

The main issue is fixed as of #109.

@cshadek
Copy link
Contributor Author

cshadek commented Mar 13, 2023

Since the main issue is fixed, I created a new issue #110 to discuss other improvements to connections that were mentioned above.

@cshadek cshadek closed this as completed Mar 13, 2023
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

2 participants