29 Commits
Author SHA1 Message Date
lewisf 5fa4525869 Revert "Add typeName for nested property objects (#294)"
This reverts commit 3161d224d7.
2017-11-25 23:06:42 -08:00
Sirui Li 3161d224d7 Add typeName for nested property objects (#294)
* Add typeName for nested property objects

* Add test for Flow

* Add typeName for nested property objects for TypeScript
2017-11-25 14:52:27 -08:00
Piotr Małecki-Jurek 4cd6ae9e73 Correct typename values for fragments on non-abstract types (#251) 2017-10-14 09:34:15 +02:00
Piotr Czarnecki 4825284211 Allow multiline comments in enums 2017-08-30 10:02:19 +02:00
Martijn Walraven d74b5749ed Move schemas to test/fixtures and some test clean up 2017-08-14 17:05:24 +02:00
Martijn Walraven 3bcaa8c603 Initial version of new compiler and IR 2017-08-14 17:05:24 +02:00
Robin Ricard b5113cb28a Top-line __typename is not a string anymore (#188)
* Top-line __typename is not a string anymore

Replaced with the correct type name

Fixes #183

* Test the cases described in #183
2017-07-25 23:04:46 +02:00
Robin Ricard d8f6a6d157 Detect inner array elements that are nullable and mark them as nullable (#186)
* Detect inner array elements that are nullable and mark them as nullable

Fixes #122

* Test non-null array elements as well
2017-07-25 22:26:57 +02:00
Lewis Chung c866a123f1 support multiline comments in flow/typescript (#149) 2017-06-26 10:45:21 +02:00
Robin Ricard 2e50dbc336 Improve handling of fragments for Flow/Typescript targets (#143)
* Don’t Swift-ify meta field names - they shouldn’t look like regular fields (#97)

* Fix addTypename for Swift target

* Revert "Use disjoint unions on fragments w/ interfaces (#86)"

This reverts commit c5452824e5.

* progress

* fix fragment spread handling

* handle __typename fields by properly generating types with string literals based on type condition

* fix handling of fragment spreads and inline fragments within fragments on concrete type conditions

* Fix handling property declarations of concrete types

* use updates to IR from #128

* rehook up add-typename

* fix up tests by passing in addTypename: true

* remove some unnecessary fields

* add comments to confusing bits

* Fixed several issues post-rebase

During the rebase I mainly favored master but this PR rolled back features from there. This PR mainly fixes that.

* copy over flow target updates to typescript target

* Fix a few indentation issues

* fix rebase error on validations

* ExplicitTypename should only error on the swift target

* fix missed rebase
2017-06-22 09:11:22 -07:00
Martijn Walraven faa5715aee New Swift target (#128)
This bundles changes to support a new Swift target for Apollo iOS.
2017-06-06 17:04:55 +02:00
Lewis Chung c5452824e5 Use disjoint unions on fragments w/ interfaces (#86)
* Handle fragment interfaces better

Instead of concat'ing inline fragment fields, it makes more sense
to create a type for each inline fragment and then union'ing them.

* Implement typescript inline fragment interfaces

* Update typescript snapshots

* Remove explicit typename validation for non-Swift targets

* Do not set description on field for __typename

If we're allowing explicit typename, we cannot make the assumption
that every field is a normal field -- rather that some fields
are introspection fields that do not have a description.

* Retrieve the __typename from the parentType

* remove console.log

* some minor fixes

* Handle fragment interfaces better

Instead of concat'ing inline fragment fields, it makes more sense
to create a type for each inline fragment and then union'ing them.

* Implement typescript inline fragment interfaces

* Update typescript snapshots

* Only generate typename within the flow/typescript codegen instead of adding it to the IR

* Fix fragments in various areas

- Fix fragments that are in selection sets that are not fragments
- Fix fragments in fragment on interface in fragment on interface
- Ensure works with type alias

* Use better unique names to name resulting fragment types

- If inline fragments in fragments, nothing changes
- If inline fragments in a selection set that is not part of a fragment,
use the operation name as the suffix.

* get __typename added to all the right places

* Handle fragment interfaces better

Instead of concat'ing inline fragment fields, it makes more sense
to create a type for each inline fragment and then union'ing them.

* Implement typescript inline fragment interfaces

* Update typescript snapshots

* Remove explicit typename validation for non-Swift targets

* Do not set description on field for __typename

If we're allowing explicit typename, we cannot make the assumption
that every field is a normal field -- rather that some fields
are introspection fields that do not have a description.

* Retrieve the __typename from the parentType

* remove console.log

* some minor fixes

* Only generate typename within the flow/typescript codegen instead of adding it to the IR

* Fix fragments in various areas

- Fix fragments that are in selection sets that are not fragments
- Fix fragments in fragment on interface in fragment on interface
- Ensure works with type alias

* Use better unique names to name resulting fragment types

- If inline fragments in fragments, nothing changes
- If inline fragments in a selection set that is not part of a fragment,
use the operation name as the suffix.

* get __typename added to all the right places

* downgrade inflected
2017-05-09 20:35:11 -07:00
lewisf 96201c79e6 Remove usage of 2017-04-23 10:37:49 -07:00
lewisf 589ea809f9 Move expectations/assertions and syntax to Jest
- it(name: string, test: function) => test(name: string, test: function)
- Use jest expectations
- Remove chai
2017-04-23 10:32:44 -07:00
lewisf 5e06fbdef3 fix all tests by moving to snapshots 2017-04-22 22:16:52 -07:00
Jacob Kristhammar d025f49b6b Fix bug with inconsistent fragment capitalization (#79) 2017-03-21 23:51:42 +01:00
Stefan Dobrev a32ed2ef01 Fix new line at the end of TypeScript code generation (#50)
It turned out that TypeScript generated files does not end with a new
line character. The issue lies in the fact that
`generator.printOnNewline()` method was used that accepts a string
parameter. If the string is `falsy` it does nothing. The fix is to use
`printNewline()` method instead.

The tests were passing because the tag helper `stripIndent` is deleting
the new line charter when the line is ‘empty’. The tests are fixed by
appending the new line character to the expected value.
2017-02-06 10:54:40 +01:00
Martijn Walraven b39a733b4c Use input object field name instead of property name
Fixes apollographql/apollo-ios#47.
2017-02-01 21:38:49 +01:00
Adir Amsalem 0f7bc644d5 disable tslint in generated file (#39) 2017-01-26 10:47:25 -08:00
Robin Ricard 11f87c5f35 Reapply 3cea692 from @dotansimha
For some reason it was not properly applied during the merge.

Fixes #19
2016-12-10 16:00:22 +01:00
Martijn Walraven a90cf59a4a Extract serializeToJSON and include type information in typesUsed 2016-12-06 12:32:19 +01:00
Robin Ricard e72d56be21 Add input object types support in TS 2016-12-05 23:57:58 +01:00
Robin Ricard 7beb23f911 Add failing test for Input Objects 2016-12-05 20:40:05 +01:00
Robin Ricard 257521f069 Add inline fragments as forced optional fields 2016-12-05 20:17:31 +01:00
Robin Ricard f30a68bead Add fragment spreads 2016-12-05 20:17:31 +01:00
Robin Ricard 5d7a079be1 Simpler test to cover absence of variables 2016-12-05 20:17:31 +01:00
Robin Ricard f311d66a2e Complex selection set wrapping 2016-12-05 20:17:31 +01:00
Robin Ricard 3aa0ee1d23 Fix enum declarations 2016-12-05 20:17:31 +01:00
Robin Ricard e40a43efe6 Add a passing test with the current generator 2016-12-05 20:17:31 +01:00