-
Notifications
You must be signed in to change notification settings - Fork 734
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
Support Include/Skip in generated selection set initializers #2869
Conversation
@@ -212,7 +212,7 @@ public struct ClassroomPetDetails: AnimalKingdomAPI.SelectionSet, Fragment { | |||
/// Parent Type: `Bird` | |||
public struct AsBird: AnimalKingdomAPI.InlineFragment { | |||
public let __data: DataDict | |||
public init(data: DataDict) { __data = data } | |||
public init(_dataDict: DataDict) { __data = _dataDict } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this underscored param in a public api supposed to be unnamed, and there’s a missing space? Otherwise seems a strange change. Is it to deter people from using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is to indicate that it's an internal API that needs to be public
only because it's used by generated code. You should not be calling it yourself.
In my next PR, I'll be adding a warning to the documentation of this initializer that it should not be called outside of generated code.
@AnthonyMDev I'm noticing that even though this change has been made to the |
@farshid1, I can't seem to find reference to initializers in Some things that may help track down the issue:
|
You are absolutely correct. Looks like I had installed the package through Xcode once and another time when I migrated my app to use |
Glad it's working now. |
This required a significant change to the way we hold the data for
SelectionSet
s in memory. During GraphQL Execution, we now create theDataDict
for each individual entity. This includes their object type and variables.Now, the variables on each nested entity are used to evaluate if their fields conditions are fulfilled, rather than looking at the global variables for each operation. This allows us to generate initializers for nested entities that override the inclusion condition values.
The same concept also applies to the object type and the
implementedInterfaces
that are used to determine type conversions.This means that you cannot just initialize a
SelectionSet
with raw JSON anymore. The data needs to be transformed. There is now aSelectionSet.init(data: JSONObject, variables: GraphQLOperation.Variables?) throws
function that runs a bare bones version of theGraphQLExecutor
applying the needed transformations and validating that the data is correct. This means the function is no longer unsafe, as it throws on invalid data.