{"action":"created","issue":{"url":"https://api.github.com/repos/apollographql/apollo-android/issues/382","repository_url":"https://api.github.com/repos/apollographql/apollo-android","labels_url":"https://api.github.com/repos/apollographql/apollo-android/issues/382/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/apollo-android/issues/382/comments","events_url":"https://api.github.com/repos/apollographql/apollo-android/issues/382/events","html_url":"https://github.com/apollographql/apollo-android/issues/382","id":218585202,"number":382,"title":"IR Fragment TypeConditions and PossibleTypes","user":{"login":"BenSchwab","id":1754153,"avatar_url":"https://avatars3.githubusercontent.com/u/1754153?v=3","gravatar_id":"","url":"https://api.github.com/users/BenSchwab","html_url":"https://github.com/BenSchwab","followers_url":"https://api.github.com/users/BenSchwab/followers","following_url":"https://api.github.com/users/BenSchwab/following{/other_user}","gists_url":"https://api.github.com/users/BenSchwab/gists{/gist_id}","starred_url":"https://api.github.com/users/BenSchwab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenSchwab/subscriptions","organizations_url":"https://api.github.com/users/BenSchwab/orgs","repos_url":"https://api.github.com/users/BenSchwab/repos","events_url":"https://api.github.com/users/BenSchwab/events{/privacy}","received_events_url":"https://api.github.com/users/BenSchwab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-31T18:46:40Z","updated_at":"2017-03-31T18:47:50Z","closed_at":null,"body":"Consider the following IR file:\r\n\r\nWe use a `HeroDetails` fragment (defined on `Character`) on a `Character`.\r\n\r\nThis fragment can be used on the `Character` interface, or on a `Human` or `Droid` as described in `possibleTypes`.\r\n\r\nCurrently, we only look at `possibleTypes` in code-gen, but is it possible (safe?) to also use `typeCondition` on the fragment IR json? \r\n\r\nIf so, this would enable more intelligent code gen. i.e. of the `type` of field in a which a fragment is used `isElementOf (fragment.type || fragment.possibleTypes)` then we can generate the fragment as `@NonNull` or non optional, as it is guaranteed to be on the fragment. \r\n\r\n(In fragment heavy code, this false nullability is becoming a nuisance.) \r\n\r\n```\r\n{\r\n    \"operations\": [\r\n        {\r\n            \"filePath\": \"src/test/graphql/com/example/simple_fragment/TestQuery.graphql\",\r\n            \"operationName\": \"TestQuery\",\r\n            \"operationType\": \"query\",\r\n            \"variables\": [],\r\n            \"source\": \"query TestQuery {\\n  hero {\\n    __typename\\n    ...HeroDetails\\n  }\\n}\",\r\n            \"fields\": [\r\n                {\r\n                    \"responseName\": \"hero\",\r\n                    \"fieldName\": \"hero\",\r\n                    \"type\": \"Character\",\r\n                    \"fields\": [],\r\n                    \"fragmentSpreads\": [\r\n                        \"HeroDetails\"\r\n                    ],\r\n                    \"inlineFragments\": []\r\n                }\r\n            ],\r\n            \"fragmentsReferenced\": [\r\n                \"HeroDetails\"\r\n            ]\r\n        }\r\n    ],\r\n    \"fragments\": [\r\n        {\r\n            \"filePath\": \"src/test/graphql/com/example/simple_fragment/TestQuery.graphql\",\r\n            \"fragmentName\": \"HeroDetails\",\r\n            \"source\": \"fragment HeroDetails on Character {\\n  __typename\\n  name\\n}\",\r\n            \"typeCondition\": \"Character\",\r\n            \"possibleTypes\": [\r\n                \"Human\",\r\n                \"Droid\"\r\n            ],\r\n            \"fields\": [\r\n                {\r\n                    \"responseName\": \"name\",\r\n                    \"fieldName\": \"name\",\r\n                    \"type\": \"String!\"\r\n                }\r\n            ],\r\n            \"fragmentSpreads\": [],\r\n            \"inlineFragments\": [],\r\n            \"fragmentsReferenced\": []\r\n        }\r\n    ],\r\n    \"typesUsed\": []\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/apollographql/apollo-android/issues/comments/290796928","html_url":"https://github.com/apollographql/apollo-android/issues/382#issuecomment-290796928","issue_url":"https://api.github.com/repos/apollographql/apollo-android/issues/382","id":290796928,"user":{"login":"BenSchwab","id":1754153,"avatar_url":"https://avatars3.githubusercontent.com/u/1754153?v=3","gravatar_id":"","url":"https://api.github.com/users/BenSchwab","html_url":"https://github.com/BenSchwab","followers_url":"https://api.github.com/users/BenSchwab/followers","following_url":"https://api.github.com/users/BenSchwab/following{/other_user}","gists_url":"https://api.github.com/users/BenSchwab/gists{/gist_id}","starred_url":"https://api.github.com/users/BenSchwab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenSchwab/subscriptions","organizations_url":"https://api.github.com/users/BenSchwab/orgs","repos_url":"https://api.github.com/users/BenSchwab/repos","events_url":"https://api.github.com/users/BenSchwab/events{/privacy}","received_events_url":"https://api.github.com/users/BenSchwab/received_events","type":"User","site_admin":false},"created_at":"2017-03-31T18:47:50Z","updated_at":"2017-03-31T18:47:50Z","body":"@sav007 Please edit / comment if what I wrote does not make sense\r\n @martijnwalraven You may have mentioned that `typeCondition` is deprecated?"}}
{"actor":{"display_login":"BenSchwab"}}