-
Notifications
You must be signed in to change notification settings - Fork 731
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
[RFC] In Progress - Release 1.0 - Swift Codegen #1876
Conversation
4f7b4e1
to
a7d11c8
Compare
fa5d804
to
9226572
Compare
9226572
to
8188979
Compare
This reverts commit f084ca7.
* Add Swift codegen engine argument test * Update test function names to match #1849 * Remove test file attribution header
* Revert "Remove inflection option, pluralizer and dependency" * Move from InflectorKit fork to origin with 1.0.0 minimum * Update to comply with InflectorKit 1.0.0 deprecations * Enable code generation options to accept additional inflection rules * Update PluralizerTest function names to match #1849 * Shuffle parameter documentation order to match parameter input order
This reverts commit 05c46a1.
8188979
to
ff35066
Compare
…to release/1.0-alpha-incubating # Conflicts: # Apollo.xcodeproj/project.pbxproj
Squashed commit of the following: commit cf5c3ec Author: Anthony Miller <[email protected]> Date: Wed Sep 22 11:21:23 2021 -0700 cleanup commit 3d329e6 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 18:42:22 2021 -0700 clean up on proposal document commit cf43742 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 18:35:52 2021 -0700 Add CodegenProposal.md & clean up project structure commit c4fafc7 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 17:47:26 2021 -0700 clean up commit e9896a6 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 14:32:26 2021 -0700 Finish boolean condition selections commit 164e748 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 13:57:03 2021 -0700 Improve typeCase selection to use parent type of type case object commit 2dd3c84 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 13:35:49 2021 -0700 Fix configurations for test target deployment target commit 9c2aa81 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 12:54:36 2021 -0700 WIP: boolean condition selections commit 85f87c5 Author: Anthony Miller <[email protected]> Date: Tue Sep 21 11:19:16 2021 -0700 Clean up commit 2a60f6e Author: Anthony Miller <[email protected]> Date: Mon Sep 20 16:20:56 2021 -0700 Fix CachePersistentTests commit 97a4652 Author: Anthony Miller <[email protected]> Date: Mon Sep 20 16:18:09 2021 -0700 Add fragmentSpread convenience initializer to selection commit 6f5e31e Author: Anthony Miller <[email protected]> Date: Mon Sep 20 16:16:54 2021 -0700 Fix ParseQueryResponseTests commit 92fc3b2 Author: Anthony Miller <[email protected]> Date: Mon Sep 20 16:16:24 2021 -0700 Fragment selection execution does not require runtime type checking Only type cases would need to be checked. commit c5fe4c7 Author: Anthony Miller <[email protected]> Date: Mon Sep 20 13:33:20 2021 -0700 Fix more tests commit 87011b9 Author: Anthony Miller <[email protected]> Date: Mon Sep 20 13:21:17 2021 -0700 Remove selection set typename checking tests As long as the nested selections are all valid, it doesn't matter if the typename is correct commit a1db64a Author: Anthony Miller <[email protected]> Date: Mon Sep 20 13:20:30 2021 -0700 Add more tests for child selection set typename checking commit a1a6d60 Author: Anthony Miller <[email protected]> Date: Mon Sep 20 12:25:05 2021 -0700 Fix test commit 4bd5a93 Author: Anthony Miller <[email protected]> Date: Mon Sep 20 12:18:35 2021 -0700 Fixing bugs commit cc882a0 Author: Anthony Miller <[email protected]> Date: Thu Sep 16 17:57:34 2021 -0700 SelectionSetMapper handles custom scalars now commit ccf59fd Author: Anthony Miller <[email protected]> Date: Thu Sep 16 17:51:41 2021 -0700 Implement basic logic for execution of TypeCases commit 1aed6ad Author: Anthony Miller <[email protected]> Date: Thu Sep 16 17:43:25 2021 -0700 Fix execution of Boolean Condition fields commit ed20344 Author: Anthony Miller <[email protected]> Date: Thu Sep 16 17:21:00 2021 -0700 Make InputValue JSONEncodable & add some TODOs commit ed91ff8 Author: Anthony Miller <[email protected]> Date: Wed Sep 15 13:50:01 2021 -0700 WIP: Refactoring more unit tests commit f899731 Author: Anthony Miller <[email protected]> Date: Wed Sep 15 12:52:45 2021 -0700 Merge CacheKey and CacheReference in ApolloAPI commit 57ab751 Author: Anthony Miller <[email protected]> Date: Mon Sep 13 15:35:01 2021 -0700 Refactoring tests and clean up commit 8f37f2c Author: Anthony Miller <[email protected]> Date: Mon Sep 13 15:07:37 2021 -0700 Attach schema to AnySelectionSet - Executor and Response dont need schema passed to them commit e20904a Author: Anthony Miller <[email protected]> Date: Mon Sep 13 11:43:11 2021 -0700 Improve test mock objects commit b4f4c68 Author: Anthony Miller <[email protected]> Date: Mon Sep 13 11:41:31 2021 -0700 Refactor WebSocketTransport to use configuration struct commit dfc56fb Author: Anthony Miller <[email protected]> Date: Fri Sep 10 19:38:44 2021 -0700 WIP: Refactor StarwarsAPI to manual version of new codegen First pass - up to line 2625 commit 5cc2b2a Author: Anthony Miller <[email protected]> Date: Fri Sep 10 19:25:20 2021 -0700 API Models for TypeCases - TODO: Execution of TypeCase commit 903bd1c Author: Anthony Miller <[email protected]> Date: Fri Sep 10 17:57:09 2021 -0700 UploadAPI manually generated as new code gen commit 8d96c9c Author: Anthony Miller <[email protected]> Date: Fri Sep 10 17:56:39 2021 -0700 InputValue & OutputType Conversion protocols commit b91ac93 Author: Anthony Miller <[email protected]> Date: Fri Sep 10 17:46:03 2021 -0700 Executor handles nil FieldEntry values commit 901e7bf Author: Anthony Miller <[email protected]> Date: Fri Sep 10 17:02:09 2021 -0700 Fix accumulators to accept child objects explicitly commit 43f32ef Author: Anthony Miller <[email protected]> Date: Fri Sep 10 14:22:27 2021 -0700 Refactor Websocket to build commit 5c7af31 Author: Anthony Miller <[email protected]> Date: Fri Sep 10 12:54:53 2021 -0700 Refactored Response parsing to use new executor - Killed Decoding.swift commit 3ad6de9 Author: Anthony Miller <[email protected]> Date: Thu Sep 9 16:06:41 2021 -0700 Building SchemaConfiguration to handle cacheKey resolution commit e5fa2ca Author: Anthony Miller <[email protected]> Date: Thu Sep 9 14:50:51 2021 -0700 Cleanup commit c692d0a Author: Anthony Miller <[email protected]> Date: Thu Sep 9 14:47:06 2021 -0700 WIP: Create CacheConfiguration - Pass it down from ApolloStore commit 35a5d43 Author: Anthony Miller <[email protected]> Date: Thu Sep 9 13:06:50 2021 -0700 Refactor InputValue evaluation to accept InputValue variables commit a3e450e Author: Anthony Miller <[email protected]> Date: Thu Sep 9 12:25:56 2021 -0700 ExecutionInfo -> ObjectExecutionInfo commit 086e9b4 Author: Anthony Miller <[email protected]> Date: Thu Sep 9 12:07:33 2021 -0700 Executor Refactor - Recursive execution commit 10c8066 Author: Anthony Miller <[email protected]> Date: Thu Sep 9 11:04:27 2021 -0700 Refactor Accumulators commit 3bbce2f Author: Anthony Miller <[email protected]> Date: Thu Sep 9 09:59:38 2021 -0700 WIP: Refactor execution - Complete function commit 2b88510 Author: Anthony Miller <[email protected]> Date: Thu Sep 9 09:10:55 2021 -0700 FieldExecutionInfo will only merge selections on request commit 2c7a167 Author: Anthony Miller <[email protected]> Date: Wed Sep 8 16:26:13 2021 -0700 Refactor grouping of fields Merging selections now happens durring initial field grouping, rather than later. commit 0811558 Author: Anthony Miller <[email protected]> Date: Tue Sep 7 17:50:01 2021 -0700 WIP: Refactor GraphQLExecutor to use new Selections commit 274bc4b Author: Anthony Miller <[email protected]> Date: Tue Sep 7 15:49:21 2021 -0700 WIP: Migrate GraphQLOperation to new SelectionSet commit 2d6dbcd Author: Anthony Miller <[email protected]> Date: Tue Sep 7 14:02:07 2021 -0700 Move over expected generated output commit 89152fc Author: Anthony Miller <[email protected]> Date: Tue Sep 7 13:55:44 2021 -0700 Move over updated schema commit e7daf86 Author: Anthony Miller <[email protected]> Date: Tue Sep 7 13:53:52 2021 -0700 Move common objects into ApolloAPI
* Change InputValue.none -> .null. remove Field.Arguments * Refactor Operation Variable to cleaner dictionary * Change GraphQLMap into JSONEncodableDictionary * Handle null input values in cache key computation * Renamed Nullable to GraphQLNullable * Fixed broken tests
* Kill "sendOperationIdentifiers" option on RequestBodyCreator * Refactor GraphQLOperation definition * Add todo for implementation of persistedOperationsOnly * Change Requests per PR comments * Added operation generation to the RFC
WIP cleanup WIP cleanup
* Include metadata that allows the `GraphQLExecutor` and runtime type checking on `TypeCase`s to operate. | ||
* Can be extended to provide cache key computation for types to configure the normalized cache. | ||
* Used for interacting with the cache for manual read/write functionality. | ||
* Used to create mock objects for generated `SelectionSet`s to be used in unit tests. |
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.
I'm experimenting with this at the moment and one drawback of using schema types for mock objects generated is that schema types don't know anything about aliases. If an operation uses aliases, creating a mock for it using schema types only is a bit awkward and certainly non type safe as the alias name would have to be passed at runtime.
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.
Great point! I plan on using the schema types to build the objects, and then when you want to convert them to a specific selection set, I could run them through the GraphQLExecutor
really quickly to map any aliased fields to their correct fields.
If you want a mock of a specific SelectionSet
, you'll have to make your mock from the schema type and then run a function to convert it to the SelectionSet
. Still haven't defined the API for that exactly, but I have a decent idea of how to do that.
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.
you'll have to make your mock from the schema type and then run a function to convert it to the SelectionSet
I think that part could be the problematic one. If you have 2 field with different values, one of them being aliased, there's no real way to mock this using schema types:
query {
cat: animal(species: CAT)
dog: animal(species: DOG)
}
I'm still experimenting with this so maybe there's a convenient and idiomatic way to set aliases for schema types but it feels a bit out of place at first sight.
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.
Yeah, this is definitely a rough edge. I think there is a solution to this. We are already ignoring aliases when storing fields in the cache on iOS. The field is stored using a cache key from the actual field name. If the field has arguments, those arguments become part of the cache key. So this seems doable.
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.
Would definitely help to have a quick summary at the top of all this of what is changing from existing codegen with links to the bits that are changing.
* Merged Scalar field accessor * Direct Enity Field Accessors * WIP: Entity Fragment Merged Fields * WIP: Add MergedSources to MergedSelections * Add merged sources to entity selection tree * Broke up direct & merged selections, killed base class * Calculating when merged selections are merged * Keep track of which selections are merged from which source * Added template rendering tests * Propogate fragment spread merged source to nested fields * Make MergedSources contain FragmentSpread, not just fragment name * Calculate selection set name in Fragment * Generated direct nested selection sets * WIP: add fragment and operation file generators * WIP: Updating SwiftScripts * Add (broken) generated AnimalKingdom files
* Implement Swift code generation template for Swift Package Manager manifest * Add tests for SwiftPackageManagerModuleTemplate * Implement schema module file generator with tests * Use SchemaModuleFileGenerator in ApolloCodegen * Temporary tests to ensure we test unimplemented file generators and templates when we build them * Fix Equatable implementation for SchemaModuleFileGenerator * Add Swift Package Manager dependency for ApolloAPI in generated manifest file
* Render Operation Definition * Generation of Operation Definition 7 Clean up Swift Scripts * Added import ApolloAPI to templates * Implement Fragment Template + File Generator And change ResponseDict to DataDict in template renderer
* Render Operation Definition * Generation of Operation Definition 7 Clean up Swift Scripts * Added import ApolloAPI to templates * Implement Fragment Template + File Generator And change ResponseDict to DataDict in template renderer * Calculate generatedSelectionSetName with merging from parent and type cases * WIP: TypeCase Accessors * fixed errors after rebasing * Move caching of generated seleciton set names to object retained by SelectionSetTemplate * Calculating TypeCase Merged names * Fixing TemplateString new line removal for sections * Render Fragment Container * Render Direct TypeCase SelectionSets * Regenerate AnimalKingdom API * Render Boolean as "Bool" * Missing newline after field selections sets * Minor fix
* Render Operation Definition * Generation of Operation Definition 7 Clean up Swift Scripts * Added import ApolloAPI to templates * Implement Fragment Template + File Generator And change ResponseDict to DataDict in template renderer * Calculate generatedSelectionSetName with merging from parent and type cases * WIP: TypeCase Accessors * fixed errors after rebasing * Move caching of generated seleciton set names to object retained by SelectionSetTemplate * Calculating TypeCase Merged names * Fixing TemplateString new line removal for sections * Render Fragment Container * Render Direct TypeCase SelectionSets * Regenerate AnimalKingdom API * Render Boolean as "Bool" * Missing newline after field selections sets * Add Union and root types to referenced types in JS FrontEnd * Minor fix
* FragmentDefinition rendering & unit test fixes * Render Selection Set - Minor fixes (#2128) * Fix entity field accessor to point to correct generated selection set * Add test for merged fragment accessors * Render Merged Field and TypeCase selection sets * Change Glob to use OrderedSet to remove randomness is referencedType ordering * Fixed doubled operation type name on end of generated operation with type already appended. * Fix glob tests
…2130) * Add documentation with selection set name to rendered selection sets * Added MARKS to sections of SelectionSetTemplate
…ons (#2131) * Add documentation with selection set name to rendered selection sets * Added MARKS to sections of SelectionSetTemplate * Added missing test
* Refactor EnumFileGenerator for more functional behavior * Refactor OperationFileGenerator for more functional behavior * Add tests for OperationFileGenerator * Refactor FragmentFileGenerator for more functional behavior * Add tests for FragmentFileGenerator * Rename and refactor TypeFileGenerator for more functional behavior * Fix tests for ObjectFileGenerator and ObjectTemplate * Refactor InterfaceFileGenerator for more functional behavior * Fix InterfaceFileGeneratorTests * Refactor UnionFileGenerator for more functional behavior * Fix UnionFileGeneratorTests * Refactor InputObjectFileGenerator for more functional behavior * Fix InputObjectGeneratorTests * Fix annoying parameter naming * Refactor SchemaFileGenerator for more functional behavior * Refactor SchemaModuleFileGenerator for more functional behavior * Refactor ApolloCodegen and reduce surface area of config being passed around * Add path to ApolloCodgenConfiguration mock helper * Expose CodegenTestSupport bundle resources URL * Move GraphQLOperation name suffix logic into class for common access * Move file generators into function for testability * Add ApolloCodegen file generators integration test * Fix operation file name generation
…figs to make template easier to use (#2134)
* Implement path resolver for codegen file output configuration * Add operation path resolution to config logic * Use path resolver in ApolloCodegen * Add schema file path resolution
* Implement path resolver for codegen file output configuration * Add operation path resolution to config logic * Use path resolver in ApolloCodegen * Add schema file path resolution * Remove empty test case * Fix expected operation filename for test
These are tracked in issue #2138
* Adds the path parameter to the package target * Add generated file header comment to templates
* Update SchemaDownload for ApolloSchemaDownloadConfigurationChanges * Add command line parameter for package manager * Update dependency packages * Update generated files for AnimalKingdomAPI * Update AnimalKingdomAPI generated files for generated comment header
* Bump project version * Update SPM manifest target branch to Alpha 1 release tag * Add updated AnimalKingdomAPI generated file structure * Ignore locally generated packages * Fix file path for operation and fragment file generators * Updated changelog for 1.0.0-alpha.1 release * Disable constantly failing subscription test * Fix resolvePath tests with filenames for mocked fragments and operations
* Render Operation Variable - single variable * Operation Variables - Multiple Variables * WIP: Operation Variable - nullables * Recfactored to add InputValueRenderable Finished implementation of operation variable generation * Fix renamed but not deleted file * Add ExpressibleBy Literals to GraphQLNullable * Correct OperationVariable rendering test behavior * WIP: Implementing rendering * Fix template string indentation * Add operation variable default values to CompilationResult * Add pet adoption mutation * Add public modifier to input object template * WIP: Fixing Input Object Accessors * Add public to input object init and fields * Generate InputObject fields with dynamic member accessors * Rename input object "dict" to "data" * Added PetSearchQuery to AnimalKingdom API * Fixed rendering of input enum values * Fixed conversion of default value dictionary literal to InputObject * WIP * Restructured tests to be accurate for behavior with initializing inpuit object default values directly * Changed Implementation for direct input value initialization * WIP: FieldArgument Rendering * Fix field argument rendering to use literals * Regenerate AnimalKingdomAPI with field arguments
…ing (#2169) * Render Operation Variable - single variable * Operation Variables - Multiple Variables * WIP: Operation Variable - nullables * Recfactored to add InputValueRenderable Finished implementation of operation variable generation * Fix renamed but not deleted file * Add ExpressibleBy Literals to GraphQLNullable * Correct OperationVariable rendering test behavior * WIP: Implementing rendering * Fix template string indentation * Add operation variable default values to CompilationResult * Add pet adoption mutation * Add public modifier to input object template * WIP: Fixing Input Object Accessors * Add public to input object init and fields * Generate InputObject fields with dynamic member accessors * Rename input object "dict" to "data" * Added PetSearchQuery to AnimalKingdom API * Fixed rendering of input enum values * Fixed conversion of default value dictionary literal to InputObject * WIP * Restructured tests to be accurate for behavior with initializing inpuit object default values directly * Changed Implementation for direct input value initialization * WIP: FieldArgument Rendering * Fix field argument rendering to use literals * Regenerate AnimalKingdomAPI with field arguments * Ensure SelectionSet field accessors are generated with swift camelCasing
This PR was closed when we deleted the |
This is the current working branch for the 1.0 release candidate.
The primary focus of the 1.0 release is a reimagining of the generated GraphQL operation models. This includes a major overhaul of the internal model and execution layer and a re-write of the code generation engine in Swift.
An RFC for the new format of the generated GraphQL operation models is provided as part of this PR.
Please make comments on this RFC as a review of this PR.
The full rich text of the RFC can be found at CodegenProposal.md
IN PROGRESS - DO NOT MERGE
1.0.0
.main
and releasing them.main
.