diff --git a/base/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.c b/head/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.c
index 125beb1..a6f3017 100644
--- a/base/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.c
+++ b/head/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.c
@@ -5,23 +5,23 @@
 
 #include "TopLevel.h"
 
-struct Connection * cJSON_ParseConnection(const char * s) {
-    struct Connection * x = NULL;
+struct RepositoryRepositoryConnection * cJSON_ParseRepositoryRepositoryConnection(const char * s) {
+    struct RepositoryRepositoryConnection * x = NULL;
     if (NULL != s) {
         cJSON * j = cJSON_Parse(s);
         if (NULL != j) {
-            x = cJSON_GetConnectionValue(j);
+            x = cJSON_GetRepositoryRepositoryConnectionValue(j);
             cJSON_Delete(j);
         }
     }
     return x;
 }
 
-struct Connection * cJSON_GetConnectionValue(const cJSON * j) {
-    struct Connection * x = NULL;
+struct RepositoryRepositoryConnection * cJSON_GetRepositoryRepositoryConnectionValue(const cJSON * j) {
+    struct RepositoryRepositoryConnection * x = NULL;
     if (NULL != j) {
-        if (NULL != (x = cJSON_malloc(sizeof(struct Connection)))) {
-            memset(x, 0, sizeof(struct Connection));
+        if (NULL != (x = cJSON_malloc(sizeof(struct RepositoryRepositoryConnection)))) {
+            memset(x, 0, sizeof(struct RepositoryRepositoryConnection));
             if (cJSON_HasObjectItem(j, "totalCount")) {
                 x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
             }
@@ -30,7 +30,7 @@ struct Connection * cJSON_GetConnectionValue(const cJSON * j) {
     return x;
 }
 
-cJSON * cJSON_CreateConnection(const struct Connection * x) {
+cJSON * cJSON_CreateRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x) {
     cJSON * j = NULL;
     if (NULL != x) {
         if (NULL != (j = cJSON_CreateObject())) {
@@ -40,10 +40,10 @@ cJSON * cJSON_CreateConnection(const struct Connection * x) {
     return j;
 }
 
-char * cJSON_PrintConnection(const struct Connection * x) {
+char * cJSON_PrintRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x) {
     char * s = NULL;
     if (NULL != x) {
-        cJSON * j = cJSON_CreateConnection(x);
+        cJSON * j = cJSON_CreateRepositoryRepositoryConnection(x);
         if (NULL != j) {
             s = cJSON_Print(j);
             cJSON_Delete(j);
@@ -52,7 +52,166 @@ char * cJSON_PrintConnection(const struct Connection * x) {
     return s;
 }
 
-void cJSON_DeleteConnection(struct Connection * x) {
+void cJSON_DeleteRepositoryRepositoryConnection(struct RepositoryRepositoryConnection * x) {
+    if (NULL != x) {
+        cJSON_free(x);
+    }
+}
+
+struct IssueConnection * cJSON_ParseIssueConnection(const char * s) {
+    struct IssueConnection * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetIssueConnectionValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct IssueConnection * cJSON_GetIssueConnectionValue(const cJSON * j) {
+    struct IssueConnection * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct IssueConnection)))) {
+            memset(x, 0, sizeof(struct IssueConnection));
+            if (cJSON_HasObjectItem(j, "totalCount")) {
+                x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateIssueConnection(const struct IssueConnection * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            cJSON_AddNumberToObject(j, "totalCount", x->total_count);
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintIssueConnection(const struct IssueConnection * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateIssueConnection(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteIssueConnection(struct IssueConnection * x) {
+    if (NULL != x) {
+        cJSON_free(x);
+    }
+}
+
+struct StargazerConnection * cJSON_ParseStargazerConnection(const char * s) {
+    struct StargazerConnection * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetStargazerConnectionValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct StargazerConnection * cJSON_GetStargazerConnectionValue(const cJSON * j) {
+    struct StargazerConnection * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct StargazerConnection)))) {
+            memset(x, 0, sizeof(struct StargazerConnection));
+            if (cJSON_HasObjectItem(j, "totalCount")) {
+                x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateStargazerConnection(const struct StargazerConnection * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            cJSON_AddNumberToObject(j, "totalCount", x->total_count);
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintStargazerConnection(const struct StargazerConnection * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateStargazerConnection(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteStargazerConnection(struct StargazerConnection * x) {
+    if (NULL != x) {
+        cJSON_free(x);
+    }
+}
+
+struct UserConnection * cJSON_ParseUserConnection(const char * s) {
+    struct UserConnection * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetUserConnectionValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct UserConnection * cJSON_GetUserConnectionValue(const cJSON * j) {
+    struct UserConnection * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct UserConnection)))) {
+            memset(x, 0, sizeof(struct UserConnection));
+            if (cJSON_HasObjectItem(j, "totalCount")) {
+                x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateUserConnection(const struct UserConnection * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            cJSON_AddNumberToObject(j, "totalCount", x->total_count);
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintUserConnection(const struct UserConnection * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateUserConnection(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteUserConnection(struct UserConnection * x) {
     if (NULL != x) {
         cJSON_free(x);
     }
@@ -84,16 +243,16 @@ struct Repository * cJSON_GetRepositoryValue(const cJSON * j) {
                 }
             }
             if (cJSON_HasObjectItem(j, "stargazers")) {
-                x->stargazers = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "stargazers"));
+                x->stargazers = cJSON_GetStargazerConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "stargazers"));
             }
             if (cJSON_HasObjectItem(j, "forks")) {
-                x->forks = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "forks"));
+                x->forks = cJSON_GetRepositoryRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "forks"));
             }
             if (cJSON_HasObjectItem(j, "watchers")) {
-                x->watchers = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "watchers"));
+                x->watchers = cJSON_GetUserConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "watchers"));
             }
             if (cJSON_HasObjectItem(j, "issues")) {
-                x->issues = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "issues"));
+                x->issues = cJSON_GetIssueConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "issues"));
             }
         }
     }
@@ -110,10 +269,10 @@ cJSON * cJSON_CreateRepository(const struct Repository * x) {
             else {
                 cJSON_AddStringToObject(j, "name", "");
             }
-            cJSON_AddItemToObject(j, "stargazers", cJSON_CreateConnection(x->stargazers));
-            cJSON_AddItemToObject(j, "forks", cJSON_CreateConnection(x->forks));
-            cJSON_AddItemToObject(j, "watchers", cJSON_CreateConnection(x->watchers));
-            cJSON_AddItemToObject(j, "issues", cJSON_CreateConnection(x->issues));
+            cJSON_AddItemToObject(j, "stargazers", cJSON_CreateStargazerConnection(x->stargazers));
+            cJSON_AddItemToObject(j, "forks", cJSON_CreateRepositoryRepositoryConnection(x->forks));
+            cJSON_AddItemToObject(j, "watchers", cJSON_CreateUserConnection(x->watchers));
+            cJSON_AddItemToObject(j, "issues", cJSON_CreateIssueConnection(x->issues));
         }
     }
     return j;
@@ -137,16 +296,16 @@ void cJSON_DeleteRepository(struct Repository * x) {
             cJSON_free(x->name);
         }
         if (NULL != x->stargazers) {
-            cJSON_DeleteConnection(x->stargazers);
+            cJSON_DeleteStargazerConnection(x->stargazers);
         }
         if (NULL != x->forks) {
-            cJSON_DeleteConnection(x->forks);
+            cJSON_DeleteRepositoryRepositoryConnection(x->forks);
         }
         if (NULL != x->watchers) {
-            cJSON_DeleteConnection(x->watchers);
+            cJSON_DeleteUserConnection(x->watchers);
         }
         if (NULL != x->issues) {
-            cJSON_DeleteConnection(x->issues);
+            cJSON_DeleteIssueConnection(x->issues);
         }
         cJSON_free(x);
     }
@@ -213,23 +372,23 @@ void cJSON_DeleteRepositoryEdge(struct RepositoryEdge * x) {
     }
 }
 
-struct RepositoryConnection * cJSON_ParseRepositoryConnection(const char * s) {
-    struct RepositoryConnection * x = NULL;
+struct UserRepositoryConnection * cJSON_ParseUserRepositoryConnection(const char * s) {
+    struct UserRepositoryConnection * x = NULL;
     if (NULL != s) {
         cJSON * j = cJSON_Parse(s);
         if (NULL != j) {
-            x = cJSON_GetRepositoryConnectionValue(j);
+            x = cJSON_GetUserRepositoryConnectionValue(j);
             cJSON_Delete(j);
         }
     }
     return x;
 }
 
-struct RepositoryConnection * cJSON_GetRepositoryConnectionValue(const cJSON * j) {
-    struct RepositoryConnection * x = NULL;
+struct UserRepositoryConnection * cJSON_GetUserRepositoryConnectionValue(const cJSON * j) {
+    struct UserRepositoryConnection * x = NULL;
     if (NULL != j) {
-        if (NULL != (x = cJSON_malloc(sizeof(struct RepositoryConnection)))) {
-            memset(x, 0, sizeof(struct RepositoryConnection));
+        if (NULL != (x = cJSON_malloc(sizeof(struct UserRepositoryConnection)))) {
+            memset(x, 0, sizeof(struct UserRepositoryConnection));
             if ((cJSON_HasObjectItem(j, "edges")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "edges")))) {
                 list_t * x1 = list_create(false, NULL);
                 if (NULL != x1) {
@@ -251,7 +410,7 @@ struct RepositoryConnection * cJSON_GetRepositoryConnectionValue(const cJSON * j
     return x;
 }
 
-cJSON * cJSON_CreateRepositoryConnection(const struct RepositoryConnection * x) {
+cJSON * cJSON_CreateUserRepositoryConnection(const struct UserRepositoryConnection * x) {
     cJSON * j = NULL;
     if (NULL != x) {
         if (NULL != (j = cJSON_CreateObject())) {
@@ -278,10 +437,10 @@ cJSON * cJSON_CreateRepositoryConnection(const struct RepositoryConnection * x)
     return j;
 }
 
-char * cJSON_PrintRepositoryConnection(const struct RepositoryConnection * x) {
+char * cJSON_PrintUserRepositoryConnection(const struct UserRepositoryConnection * x) {
     char * s = NULL;
     if (NULL != x) {
-        cJSON * j = cJSON_CreateRepositoryConnection(x);
+        cJSON * j = cJSON_CreateUserRepositoryConnection(x);
         if (NULL != j) {
             s = cJSON_Print(j);
             cJSON_Delete(j);
@@ -290,7 +449,7 @@ char * cJSON_PrintRepositoryConnection(const struct RepositoryConnection * x) {
     return s;
 }
 
-void cJSON_DeleteRepositoryConnection(struct RepositoryConnection * x) {
+void cJSON_DeleteUserRepositoryConnection(struct UserRepositoryConnection * x) {
     if (NULL != x) {
         if (NULL != x->edges) {
             struct RepositoryEdge * x1 = list_get_head(x->edges);
@@ -306,6 +465,59 @@ void cJSON_DeleteRepositoryConnection(struct RepositoryConnection * x) {
     }
 }
 
+struct StarredRepositoryConnection * cJSON_ParseStarredRepositoryConnection(const char * s) {
+    struct StarredRepositoryConnection * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetStarredRepositoryConnectionValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct StarredRepositoryConnection * cJSON_GetStarredRepositoryConnectionValue(const cJSON * j) {
+    struct StarredRepositoryConnection * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct StarredRepositoryConnection)))) {
+            memset(x, 0, sizeof(struct StarredRepositoryConnection));
+            if (cJSON_HasObjectItem(j, "totalCount")) {
+                x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateStarredRepositoryConnection(const struct StarredRepositoryConnection * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            cJSON_AddNumberToObject(j, "totalCount", x->total_count);
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintStarredRepositoryConnection(const struct StarredRepositoryConnection * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateStarredRepositoryConnection(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteStarredRepositoryConnection(struct StarredRepositoryConnection * x) {
+    if (NULL != x) {
+        cJSON_free(x);
+    }
+}
+
 struct User * cJSON_ParseUser(const char * s) {
     struct User * x = NULL;
     if (NULL != s) {
@@ -332,10 +544,10 @@ struct User * cJSON_GetUserValue(const cJSON * j) {
                 }
             }
             if (cJSON_HasObjectItem(j, "starredRepositories")) {
-                x->starred_repositories = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "starredRepositories"));
+                x->starred_repositories = cJSON_GetStarredRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "starredRepositories"));
             }
             if (cJSON_HasObjectItem(j, "repositories")) {
-                x->repositories = cJSON_GetRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "repositories"));
+                x->repositories = cJSON_GetUserRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "repositories"));
             }
         }
     }
@@ -352,8 +564,8 @@ cJSON * cJSON_CreateUser(const struct User * x) {
             else {
                 cJSON_AddStringToObject(j, "login", "");
             }
-            cJSON_AddItemToObject(j, "starredRepositories", cJSON_CreateConnection(x->starred_repositories));
-            cJSON_AddItemToObject(j, "repositories", cJSON_CreateRepositoryConnection(x->repositories));
+            cJSON_AddItemToObject(j, "starredRepositories", cJSON_CreateStarredRepositoryConnection(x->starred_repositories));
+            cJSON_AddItemToObject(j, "repositories", cJSON_CreateUserRepositoryConnection(x->repositories));
         }
     }
     return j;
@@ -377,10 +589,10 @@ void cJSON_DeleteUser(struct User * x) {
             cJSON_free(x->login);
         }
         if (NULL != x->starred_repositories) {
-            cJSON_DeleteConnection(x->starred_repositories);
+            cJSON_DeleteStarredRepositoryConnection(x->starred_repositories);
         }
         if (NULL != x->repositories) {
-            cJSON_DeleteRepositoryConnection(x->repositories);
+            cJSON_DeleteUserRepositoryConnection(x->repositories);
         }
         cJSON_free(x);
     }
diff --git a/base/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.h b/head/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.h
index d0a28eb..f576126 100644
--- a/base/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.h
+++ b/head/graphql-cjson/test/inputs/graphql/github7.graphql/default/TopLevel.h
@@ -34,30 +34,46 @@ extern "C" {
 #define cJSON_Enum (1 << 17)
 #endif
 
-struct Connection {
+struct RepositoryRepositoryConnection {
+    int64_t total_count;
+};
+
+struct IssueConnection {
+    int64_t total_count;
+};
+
+struct StargazerConnection {
+    int64_t total_count;
+};
+
+struct UserConnection {
     int64_t total_count;
 };
 
 struct Repository {
     char * name;
-    struct Connection * stargazers;
-    struct Connection * forks;
-    struct Connection * watchers;
-    struct Connection * issues;
+    struct StargazerConnection * stargazers;
+    struct RepositoryRepositoryConnection * forks;
+    struct UserConnection * watchers;
+    struct IssueConnection * issues;
 };
 
 struct RepositoryEdge {
     struct Repository * node;
 };
 
-struct RepositoryConnection {
+struct UserRepositoryConnection {
     list_t * edges;
 };
 
+struct StarredRepositoryConnection {
+    int64_t total_count;
+};
+
 struct User {
     char * login;
-    struct Connection * starred_repositories;
-    struct RepositoryConnection * repositories;
+    struct StarredRepositoryConnection * starred_repositories;
+    struct UserRepositoryConnection * repositories;
 };
 
 struct Data {
@@ -73,11 +89,29 @@ struct TopLevel {
     list_t * errors;
 };
 
-struct Connection * cJSON_ParseConnection(const char * s);
-struct Connection * cJSON_GetConnectionValue(const cJSON * j);
-cJSON * cJSON_CreateConnection(const struct Connection * x);
-char * cJSON_PrintConnection(const struct Connection * x);
-void cJSON_DeleteConnection(struct Connection * x);
+struct RepositoryRepositoryConnection * cJSON_ParseRepositoryRepositoryConnection(const char * s);
+struct RepositoryRepositoryConnection * cJSON_GetRepositoryRepositoryConnectionValue(const cJSON * j);
+cJSON * cJSON_CreateRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x);
+char * cJSON_PrintRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x);
+void cJSON_DeleteRepositoryRepositoryConnection(struct RepositoryRepositoryConnection * x);
+
+struct IssueConnection * cJSON_ParseIssueConnection(const char * s);
+struct IssueConnection * cJSON_GetIssueConnectionValue(const cJSON * j);
+cJSON * cJSON_CreateIssueConnection(const struct IssueConnection * x);
+char * cJSON_PrintIssueConnection(const struct IssueConnection * x);
+void cJSON_DeleteIssueConnection(struct IssueConnection * x);
+
+struct StargazerConnection * cJSON_ParseStargazerConnection(const char * s);
+struct StargazerConnection * cJSON_GetStargazerConnectionValue(const cJSON * j);
+cJSON * cJSON_CreateStargazerConnection(const struct StargazerConnection * x);
+char * cJSON_PrintStargazerConnection(const struct StargazerConnection * x);
+void cJSON_DeleteStargazerConnection(struct StargazerConnection * x);
+
+struct UserConnection * cJSON_ParseUserConnection(const char * s);
+struct UserConnection * cJSON_GetUserConnectionValue(const cJSON * j);
+cJSON * cJSON_CreateUserConnection(const struct UserConnection * x);
+char * cJSON_PrintUserConnection(const struct UserConnection * x);
+void cJSON_DeleteUserConnection(struct UserConnection * x);
 
 struct Repository * cJSON_ParseRepository(const char * s);
 struct Repository * cJSON_GetRepositoryValue(const cJSON * j);
@@ -91,11 +125,17 @@ cJSON * cJSON_CreateRepositoryEdge(const struct RepositoryEdge * x);
 char * cJSON_PrintRepositoryEdge(const struct RepositoryEdge * x);
 void cJSON_DeleteRepositoryEdge(struct RepositoryEdge * x);
 
-struct RepositoryConnection * cJSON_ParseRepositoryConnection(const char * s);
-struct RepositoryConnection * cJSON_GetRepositoryConnectionValue(const cJSON * j);
-cJSON * cJSON_CreateRepositoryConnection(const struct RepositoryConnection * x);
-char * cJSON_PrintRepositoryConnection(const struct RepositoryConnection * x);
-void cJSON_DeleteRepositoryConnection(struct RepositoryConnection * x);
+struct UserRepositoryConnection * cJSON_ParseUserRepositoryConnection(const char * s);
+struct UserRepositoryConnection * cJSON_GetUserRepositoryConnectionValue(const cJSON * j);
+cJSON * cJSON_CreateUserRepositoryConnection(const struct UserRepositoryConnection * x);
+char * cJSON_PrintUserRepositoryConnection(const struct UserRepositoryConnection * x);
+void cJSON_DeleteUserRepositoryConnection(struct UserRepositoryConnection * x);
+
+struct StarredRepositoryConnection * cJSON_ParseStarredRepositoryConnection(const char * s);
+struct StarredRepositoryConnection * cJSON_GetStarredRepositoryConnectionValue(const cJSON * j);
+cJSON * cJSON_CreateStarredRepositoryConnection(const struct StarredRepositoryConnection * x);
+char * cJSON_PrintStarredRepositoryConnection(const struct StarredRepositoryConnection * x);
+void cJSON_DeleteStarredRepositoryConnection(struct StarredRepositoryConnection * x);
 
 struct User * cJSON_ParseUser(const char * s);
 struct User * cJSON_GetUserValue(const cJSON * j);
diff --git a/base/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.c b/head/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.c
index 3114c69..af5298a 100644
--- a/base/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.c
+++ b/head/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.c
@@ -84,6 +84,59 @@ void cJSON_DeleteReaction(struct Reaction * x) {
     }
 }
 
+struct ReactionGroup * cJSON_ParseReactionGroup(const char * s) {
+    struct ReactionGroup * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetReactionGroupValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct ReactionGroup * cJSON_GetReactionGroupValue(const cJSON * j) {
+    struct ReactionGroup * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct ReactionGroup)))) {
+            memset(x, 0, sizeof(struct ReactionGroup));
+            if (cJSON_HasObjectItem(j, "content")) {
+                x->content = cJSON_GetReactionContentValue(cJSON_GetObjectItemCaseSensitive(j, "content"));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateReactionGroup(const struct ReactionGroup * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            cJSON_AddItemToObject(j, "content", cJSON_CreateReactionContent(x->content));
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintReactionGroup(const struct ReactionGroup * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateReactionGroup(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteReactionGroup(struct ReactionGroup * x) {
+    if (NULL != x) {
+        cJSON_free(x);
+    }
+}
+
 struct Reactable * cJSON_ParseReactable(const char * s) {
     struct Reactable * x = NULL;
     if (NULL != s) {
@@ -110,7 +163,7 @@ struct Reactable * cJSON_GetReactableValue(const cJSON * j) {
                     cJSON * e1 = NULL;
                     cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "reactionGroups");
                     cJSON_ArrayForEach(e1, j1) {
-                        list_add_tail(x1, cJSON_GetReactionValue(e1), sizeof(struct Reaction *));
+                        list_add_tail(x1, cJSON_GetReactionGroupValue(e1), sizeof(struct ReactionGroup *));
                     }
                     x->reaction_groups = x1;
                 }
@@ -128,9 +181,9 @@ cJSON * cJSON_CreateReactable(const struct Reactable * x) {
             if (NULL != x->reaction_groups) {
                 cJSON * j1 = cJSON_AddArrayToObject(j, "reactionGroups");
                 if (NULL != j1) {
-                    struct Reaction * x1 = list_get_head(x->reaction_groups);
+                    struct ReactionGroup * x1 = list_get_head(x->reaction_groups);
                     while (NULL != x1) {
-                        cJSON_AddItemToArray(j1, cJSON_CreateReaction(x1));
+                        cJSON_AddItemToArray(j1, cJSON_CreateReactionGroup(x1));
                         x1 = list_get_next(x->reaction_groups);
                     }
                 }
@@ -158,9 +211,9 @@ char * cJSON_PrintReactable(const struct Reactable * x) {
 void cJSON_DeleteReactable(struct Reactable * x) {
     if (NULL != x) {
         if (NULL != x->reaction_groups) {
-            struct Reaction * x1 = list_get_head(x->reaction_groups);
+            struct ReactionGroup * x1 = list_get_head(x->reaction_groups);
             while (NULL != x1) {
-                cJSON_DeleteReaction(x1);
+                cJSON_DeleteReactionGroup(x1);
                 x1 = list_get_next(x->reaction_groups);
             }
             list_release(x->reaction_groups);
diff --git a/base/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.h b/head/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.h
index dec95a9..acbee5b 100644
--- a/base/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.h
+++ b/head/graphql-cjson/test/inputs/graphql/github9.graphql/default/TopLevel.h
@@ -47,6 +47,10 @@ struct Reaction {
     enum ReactionContent content;
 };
 
+struct ReactionGroup {
+    enum ReactionContent content;
+};
+
 struct Reactable {
     bool viewer_can_react;
     list_t * reaction_groups;
@@ -80,6 +84,12 @@ cJSON * cJSON_CreateReaction(const struct Reaction * x);
 char * cJSON_PrintReaction(const struct Reaction * x);
 void cJSON_DeleteReaction(struct Reaction * x);
 
+struct ReactionGroup * cJSON_ParseReactionGroup(const char * s);
+struct ReactionGroup * cJSON_GetReactionGroupValue(const cJSON * j);
+cJSON * cJSON_CreateReactionGroup(const struct ReactionGroup * x);
+char * cJSON_PrintReactionGroup(const struct ReactionGroup * x);
+void cJSON_DeleteReactionGroup(struct ReactionGroup * x);
+
 struct Reactable * cJSON_ParseReactable(const char * s);
 struct Reactable * cJSON_GetReactableValue(const cJSON * j);
 cJSON * cJSON_CreateReactable(const struct Reactable * x);
diff --git a/head/graphql-cjson/test/inputs/graphql/separate-types1.graphql/default/TopLevel.c b/head/graphql-cjson/test/inputs/graphql/separate-types1.graphql/default/TopLevel.c
new file mode 100644
index 0000000..12922ca
--- /dev/null
+++ b/head/graphql-cjson/test/inputs/graphql/separate-types1.graphql/default/TopLevel.c
@@ -0,0 +1,543 @@
+/**
+ * TopLevel.c
+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
+ */
+
+#include "TopLevel.h"
+
+struct ComponentRef * cJSON_ParseComponentRef(const char * s) {
+    struct ComponentRef * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetComponentRefValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct ComponentRef * cJSON_GetComponentRefValue(const cJSON * j) {
+    struct ComponentRef * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct ComponentRef)))) {
+            memset(x, 0, sizeof(struct ComponentRef));
+            if ((cJSON_HasObjectItem(j, "id")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "id")))) {
+                x->id = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "id")));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateComponentRef(const struct ComponentRef * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            if (NULL != x->id) {
+                cJSON_AddStringToObject(j, "id", x->id);
+            }
+            else {
+                cJSON_AddNullToObject(j, "id");
+            }
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintComponentRef(const struct ComponentRef * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateComponentRef(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteComponentRef(struct ComponentRef * x) {
+    if (NULL != x) {
+        if (NULL != x->id) {
+            cJSON_free(x->id);
+        }
+        cJSON_free(x);
+    }
+}
+
+struct GridConfig * cJSON_ParseGridConfig(const char * s) {
+    struct GridConfig * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetGridConfigValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct GridConfig * cJSON_GetGridConfigValue(const cJSON * j) {
+    struct GridConfig * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct GridConfig)))) {
+            memset(x, 0, sizeof(struct GridConfig));
+            if ((cJSON_HasObjectItem(j, "items")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "items")))) {
+                list_t * x1 = list_create(false, NULL);
+                if (NULL != x1) {
+                    cJSON * e1 = NULL;
+                    cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "items");
+                    cJSON_ArrayForEach(e1, j1) {
+                        if (!cJSON_IsNull(e1)) {
+                            list_add_tail(x1, cJSON_GetComponentRefValue(e1), sizeof(struct ComponentRef *));
+                        }
+                        else {
+                            list_add_tail(x1, (void *)0xDEADBEEF, sizeof(void *));
+                        }
+                    }
+                    x->items = x1;
+                }
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateGridConfig(const struct GridConfig * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            if (NULL != x->items) {
+                cJSON * j1 = cJSON_AddArrayToObject(j, "items");
+                if (NULL != j1) {
+                    struct ComponentRef * x1 = list_get_head(x->items);
+                    while (NULL != x1) {
+                        if ((void *)0xDEADBEEF != x1) {
+                            cJSON_AddItemToArray(j1, cJSON_CreateComponentRef(x1));
+                        }
+                        else {
+                            cJSON_AddItemToArray(j1, cJSON_CreateNull());
+                        }
+                        x1 = list_get_next(x->items);
+                    }
+                }
+            }
+            else {
+                cJSON_AddNullToObject(j, "items");
+            }
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintGridConfig(const struct GridConfig * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateGridConfig(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteGridConfig(struct GridConfig * x) {
+    if (NULL != x) {
+        if (NULL != x->items) {
+            struct ComponentRef * x1 = list_get_head(x->items);
+            while (NULL != x1) {
+                if ((void *)0xDEADBEEF != x1) {
+                    cJSON_DeleteComponentRef(x1);
+                }
+                x1 = list_get_next(x->items);
+            }
+            list_release(x->items);
+        }
+        cJSON_free(x);
+    }
+}
+
+struct GridProps * cJSON_ParseGridProps(const char * s) {
+    struct GridProps * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetGridPropsValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct GridProps * cJSON_GetGridPropsValue(const cJSON * j) {
+    struct GridProps * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct GridProps)))) {
+            memset(x, 0, sizeof(struct GridProps));
+            if ((cJSON_HasObjectItem(j, "items")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "items")))) {
+                list_t * x1 = list_create(false, NULL);
+                if (NULL != x1) {
+                    cJSON * e1 = NULL;
+                    cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "items");
+                    cJSON_ArrayForEach(e1, j1) {
+                        if (!cJSON_IsNull(e1)) {
+                            list_add_tail(x1, cJSON_GetComponentRefValue(e1), sizeof(struct ComponentRef *));
+                        }
+                        else {
+                            list_add_tail(x1, (void *)0xDEADBEEF, sizeof(void *));
+                        }
+                    }
+                    x->items = x1;
+                }
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateGridProps(const struct GridProps * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            if (NULL != x->items) {
+                cJSON * j1 = cJSON_AddArrayToObject(j, "items");
+                if (NULL != j1) {
+                    struct ComponentRef * x1 = list_get_head(x->items);
+                    while (NULL != x1) {
+                        if ((void *)0xDEADBEEF != x1) {
+                            cJSON_AddItemToArray(j1, cJSON_CreateComponentRef(x1));
+                        }
+                        else {
+                            cJSON_AddItemToArray(j1, cJSON_CreateNull());
+                        }
+                        x1 = list_get_next(x->items);
+                    }
+                }
+            }
+            else {
+                cJSON_AddNullToObject(j, "items");
+            }
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintGridProps(const struct GridProps * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateGridProps(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteGridProps(struct GridProps * x) {
+    if (NULL != x) {
+        if (NULL != x->items) {
+            struct ComponentRef * x1 = list_get_head(x->items);
+            while (NULL != x1) {
+                if ((void *)0xDEADBEEF != x1) {
+                    cJSON_DeleteComponentRef(x1);
+                }
+                x1 = list_get_next(x->items);
+            }
+            list_release(x->items);
+        }
+        cJSON_free(x);
+    }
+}
+
+struct Grid * cJSON_ParseGrid(const char * s) {
+    struct Grid * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetGridValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct Grid * cJSON_GetGridValue(const cJSON * j) {
+    struct Grid * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct Grid)))) {
+            memset(x, 0, sizeof(struct Grid));
+            if ((cJSON_HasObjectItem(j, "config")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "config")))) {
+                x->config = cJSON_GetGridConfigValue(cJSON_GetObjectItemCaseSensitive(j, "config"));
+            }
+            if ((cJSON_HasObjectItem(j, "props")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "props")))) {
+                x->props = cJSON_GetGridPropsValue(cJSON_GetObjectItemCaseSensitive(j, "props"));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateGrid(const struct Grid * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            if (NULL != x->config) {
+                cJSON_AddItemToObject(j, "config", cJSON_CreateGridConfig(x->config));
+            }
+            else {
+                cJSON_AddNullToObject(j, "config");
+            }
+            if (NULL != x->props) {
+                cJSON_AddItemToObject(j, "props", cJSON_CreateGridProps(x->props));
+            }
+            else {
+                cJSON_AddNullToObject(j, "props");
+            }
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintGrid(const struct Grid * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateGrid(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteGrid(struct Grid * x) {
+    if (NULL != x) {
+        if (NULL != x->config) {
+            cJSON_DeleteGridConfig(x->config);
+        }
+        if (NULL != x->props) {
+            cJSON_DeleteGridProps(x->props);
+        }
+        cJSON_free(x);
+    }
+}
+
+struct Data * cJSON_ParseData(const char * s) {
+    struct Data * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetDataValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct Data * cJSON_GetDataValue(const cJSON * j) {
+    struct Data * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct Data)))) {
+            memset(x, 0, sizeof(struct Data));
+            if ((cJSON_HasObjectItem(j, "grid")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "grid")))) {
+                x->grid = cJSON_GetGridValue(cJSON_GetObjectItemCaseSensitive(j, "grid"));
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateData(const struct Data * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            if (NULL != x->grid) {
+                cJSON_AddItemToObject(j, "grid", cJSON_CreateGrid(x->grid));
+            }
+            else {
+                cJSON_AddNullToObject(j, "grid");
+            }
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintData(const struct Data * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateData(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteData(struct Data * x) {
+    if (NULL != x) {
+        if (NULL != x->grid) {
+            cJSON_DeleteGrid(x->grid);
+        }
+        cJSON_free(x);
+    }
+}
+
+struct Error * cJSON_ParseError(const char * s) {
+    struct Error * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetErrorValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct Error * cJSON_GetErrorValue(const cJSON * j) {
+    struct Error * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct Error)))) {
+            memset(x, 0, sizeof(struct Error));
+            if (cJSON_HasObjectItem(j, "message")) {
+                x->message = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "message")));
+            }
+            else {
+                if (NULL != (x->message = cJSON_malloc(sizeof(char)))) {
+                    x->message[0] = '\0';
+                }
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateError(const struct Error * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            if (NULL != x->message) {
+                cJSON_AddStringToObject(j, "message", x->message);
+            }
+            else {
+                cJSON_AddStringToObject(j, "message", "");
+            }
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintError(const struct Error * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateError(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteError(struct Error * x) {
+    if (NULL != x) {
+        if (NULL != x->message) {
+            cJSON_free(x->message);
+        }
+        cJSON_free(x);
+    }
+}
+
+struct TopLevel * cJSON_ParseTopLevel(const char * s) {
+    struct TopLevel * x = NULL;
+    if (NULL != s) {
+        cJSON * j = cJSON_Parse(s);
+        if (NULL != j) {
+            x = cJSON_GetTopLevelValue(j);
+            cJSON_Delete(j);
+        }
+    }
+    return x;
+}
+
+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
+    struct TopLevel * x = NULL;
+    if (NULL != j) {
+        if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
+            memset(x, 0, sizeof(struct TopLevel));
+            if ((cJSON_HasObjectItem(j, "data")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "data")))) {
+                x->data = cJSON_GetDataValue(cJSON_GetObjectItemCaseSensitive(j, "data"));
+            }
+            if (cJSON_HasObjectItem(j, "errors")) {
+                list_t * x1 = list_create(false, NULL);
+                if (NULL != x1) {
+                    cJSON * e1 = NULL;
+                    cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "errors");
+                    cJSON_ArrayForEach(e1, j1) {
+                        list_add_tail(x1, cJSON_GetErrorValue(e1), sizeof(struct Error *));
+                    }
+                    x->errors = x1;
+                }
+            }
+        }
+    }
+    return x;
+}
+
+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
+    cJSON * j = NULL;
+    if (NULL != x) {
+        if (NULL != (j = cJSON_CreateObject())) {
+            if (NULL != x->data) {
+                cJSON_AddItemToObject(j, "data", cJSON_CreateData(x->data));
+            }
+            else {
+                cJSON_AddNullToObject(j, "data");
+            }
+            if (NULL != x->errors) {
+                cJSON * j1 = cJSON_AddArrayToObject(j, "errors");
+                if (NULL != j1) {
+                    struct Error * x1 = list_get_head(x->errors);
+                    while (NULL != x1) {
+                        cJSON_AddItemToArray(j1, cJSON_CreateError(x1));
+                        x1 = list_get_next(x->errors);
+                    }
+                }
+            }
+        }
+    }
+    return j;
+}
+
+char * cJSON_PrintTopLevel(const struct TopLevel * x) {
+    char * s = NULL;
+    if (NULL != x) {
+        cJSON * j = cJSON_CreateTopLevel(x);
+        if (NULL != j) {
+            s = cJSON_Print(j);
+            cJSON_Delete(j);
+        }
+    }
+    return s;
+}
+
+void cJSON_DeleteTopLevel(struct TopLevel * x) {
+    if (NULL != x) {
+        if (NULL != x->data) {
+            cJSON_DeleteData(x->data);
+        }
+        if (NULL != x->errors) {
+            struct Error * x1 = list_get_head(x->errors);
+            while (NULL != x1) {
+                cJSON_DeleteError(x1);
+                x1 = list_get_next(x->errors);
+            }
+            list_release(x->errors);
+        }
+        cJSON_free(x);
+    }
+}
diff --git a/head/graphql-cjson/test/inputs/graphql/separate-types1.graphql/default/TopLevel.h b/head/graphql-cjson/test/inputs/graphql/separate-types1.graphql/default/TopLevel.h
new file mode 100644
index 0000000..dd98eea
--- /dev/null
+++ b/head/graphql-cjson/test/inputs/graphql/separate-types1.graphql/default/TopLevel.h
@@ -0,0 +1,113 @@
+/**
+ * TopLevel.h
+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
+ * This file depends of https://github.com/DaveGamble/cJSON, https://github.com/joelguittet/c-list and https://github.com/joelguittet/c-hashtable
+ * To parse json data from json string use the following: struct <type> * data = cJSON_Parse<type>(<string>);
+ * To get json data from cJSON object use the following: struct <type> * data = cJSON_Get<type>Value(<cjson>);
+ * To get cJSON object from json data use the following: cJSON * cjson = cJSON_Create<type>(<data>);
+ * To print json string from json data use the following: char * string = cJSON_Print<type>(<data>);
+ * To delete json data use the following: cJSON_Delete<type>(<data>);
+ */
+
+#ifndef __TOPLEVEL_H__
+#define __TOPLEVEL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <cJSON.h>
+#include <hashtable.h>
+#include <list.h>
+
+#ifndef cJSON_Bool
+#define cJSON_Bool (cJSON_True | cJSON_False)
+#endif
+#ifndef cJSON_Map
+#define cJSON_Map (1 << 16)
+#endif
+#ifndef cJSON_Enum
+#define cJSON_Enum (1 << 17)
+#endif
+
+struct ComponentRef {
+    char * id;
+};
+
+struct GridConfig {
+    list_t * items;
+};
+
+struct GridProps {
+    list_t * items;
+};
+
+struct Grid {
+    struct GridConfig * config;
+    struct GridProps * props;
+};
+
+struct Data {
+    struct Grid * grid;
+};
+
+struct Error {
+    char * message;
+};
+
+struct TopLevel {
+    struct Data * data;
+    list_t * errors;
+};
+
+struct ComponentRef * cJSON_ParseComponentRef(const char * s);
+struct ComponentRef * cJSON_GetComponentRefValue(const cJSON * j);
+cJSON * cJSON_CreateComponentRef(const struct ComponentRef * x);
+char * cJSON_PrintComponentRef(const struct ComponentRef * x);
+void cJSON_DeleteComponentRef(struct ComponentRef * x);
+
+struct GridConfig * cJSON_ParseGridConfig(const char * s);
+struct GridConfig * cJSON_GetGridConfigValue(const cJSON * j);
+cJSON * cJSON_CreateGridConfig(const struct GridConfig * x);
+char * cJSON_PrintGridConfig(const struct GridConfig * x);
+void cJSON_DeleteGridConfig(struct GridConfig * x);
+
+struct GridProps * cJSON_ParseGridProps(const char * s);
+struct GridProps * cJSON_GetGridPropsValue(const cJSON * j);
+cJSON * cJSON_CreateGridProps(const struct GridProps * x);
+char * cJSON_PrintGridProps(const struct GridProps * x);
+void cJSON_DeleteGridProps(struct GridProps * x);
+
+struct Grid * cJSON_ParseGrid(const char * s);
+struct Grid * cJSON_GetGridValue(const cJSON * j);
+cJSON * cJSON_CreateGrid(const struct Grid * x);
+char * cJSON_PrintGrid(const struct Grid * x);
+void cJSON_DeleteGrid(struct Grid * x);
+
+struct Data * cJSON_ParseData(const char * s);
+struct Data * cJSON_GetDataValue(const cJSON * j);
+cJSON * cJSON_CreateData(const struct Data * x);
+char * cJSON_PrintData(const struct Data * x);
+void cJSON_DeleteData(struct Data * x);
+
+struct Error * cJSON_ParseError(const char * s);
+struct Error * cJSON_GetErrorValue(const cJSON * j);
+cJSON * cJSON_CreateError(const struct Error * x);
+char * cJSON_PrintError(const struct Error * x);
+void cJSON_DeleteError(struct Error * x);
+
+struct TopLevel * cJSON_ParseTopLevel(const char * s);
+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j);
+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x);
+char * cJSON_PrintTopLevel(const struct TopLevel * x);
+void cJSON_DeleteTopLevel(struct TopLevel * x);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TOPLEVEL_H__ */
diff --git a/base/graphql-cplusplus/test/inputs/graphql/github7.graphql/default/quicktype.hpp b/head/graphql-cplusplus/test/inputs/graphql/github7.graphql/default/quicktype.hpp
index 9117bed..b26ad6c 100644
--- a/base/graphql-cplusplus/test/inputs/graphql/github7.graphql/default/quicktype.hpp
+++ b/head/graphql-cplusplus/test/inputs/graphql/github7.graphql/default/quicktype.hpp
@@ -88,10 +88,52 @@ namespace quicktype {
     }
     #endif
 
-    class Connection {
+    class RepositoryRepositoryConnection {
         public:
-        Connection() = default;
-        virtual ~Connection() = default;
+        RepositoryRepositoryConnection() = default;
+        virtual ~RepositoryRepositoryConnection() = default;
+
+        private:
+        int64_t total_count;
+
+        public:
+        const int64_t & get_total_count() const { return total_count; }
+        int64_t & get_mutable_total_count() { return total_count; }
+        void set_total_count(const int64_t & value) { this->total_count = value; }
+    };
+
+    class IssueConnection {
+        public:
+        IssueConnection() = default;
+        virtual ~IssueConnection() = default;
+
+        private:
+        int64_t total_count;
+
+        public:
+        const int64_t & get_total_count() const { return total_count; }
+        int64_t & get_mutable_total_count() { return total_count; }
+        void set_total_count(const int64_t & value) { this->total_count = value; }
+    };
+
+    class StargazerConnection {
+        public:
+        StargazerConnection() = default;
+        virtual ~StargazerConnection() = default;
+
+        private:
+        int64_t total_count;
+
+        public:
+        const int64_t & get_total_count() const { return total_count; }
+        int64_t & get_mutable_total_count() { return total_count; }
+        void set_total_count(const int64_t & value) { this->total_count = value; }
+    };
+
+    class UserConnection {
+        public:
+        UserConnection() = default;
+        virtual ~UserConnection() = default;
 
         private:
         int64_t total_count;
@@ -109,31 +151,31 @@ namespace quicktype {
 
         private:
         std::string name;
-        Connection stargazers;
-        Connection forks;
-        Connection watchers;
-        Connection issues;
+        StargazerConnection stargazers;
+        RepositoryRepositoryConnection forks;
+        UserConnection watchers;
+        IssueConnection issues;
 
         public:
         const std::string & get_name() const { return name; }
         std::string & get_mutable_name() { return name; }
         void set_name(const std::string & value) { this->name = value; }
 
-        const Connection & get_stargazers() const { return stargazers; }
-        Connection & get_mutable_stargazers() { return stargazers; }
-        void set_stargazers(const Connection & value) { this->stargazers = value; }
+        const StargazerConnection & get_stargazers() const { return stargazers; }
+        StargazerConnection & get_mutable_stargazers() { return stargazers; }
+        void set_stargazers(const StargazerConnection & value) { this->stargazers = value; }
 
-        const Connection & get_forks() const { return forks; }
-        Connection & get_mutable_forks() { return forks; }
-        void set_forks(const Connection & value) { this->forks = value; }
+        const RepositoryRepositoryConnection & get_forks() const { return forks; }
+        RepositoryRepositoryConnection & get_mutable_forks() { return forks; }
+        void set_forks(const RepositoryRepositoryConnection & value) { this->forks = value; }
 
-        const Connection & get_watchers() const { return watchers; }
-        Connection & get_mutable_watchers() { return watchers; }
-        void set_watchers(const Connection & value) { this->watchers = value; }
+        const UserConnection & get_watchers() const { return watchers; }
+        UserConnection & get_mutable_watchers() { return watchers; }
+        void set_watchers(const UserConnection & value) { this->watchers = value; }
 
-        const Connection & get_issues() const { return issues; }
-        Connection & get_mutable_issues() { return issues; }
-        void set_issues(const Connection & value) { this->issues = value; }
+        const IssueConnection & get_issues() const { return issues; }
+        IssueConnection & get_mutable_issues() { return issues; }
+        void set_issues(const IssueConnection & value) { this->issues = value; }
     };
 
     class RepositoryEdge {
@@ -149,10 +191,10 @@ namespace quicktype {
         void set_node(std::optional<Repository> value) { this->node = value; }
     };
 
-    class RepositoryConnection {
+    class UserRepositoryConnection {
         public:
-        RepositoryConnection() = default;
-        virtual ~RepositoryConnection() = default;
+        UserRepositoryConnection() = default;
+        virtual ~UserRepositoryConnection() = default;
 
         private:
         std::optional<std::vector<std::optional<RepositoryEdge>>> edges;
@@ -162,6 +204,20 @@ namespace quicktype {
         void set_edges(std::optional<std::vector<std::optional<RepositoryEdge>>> value) { this->edges = value; }
     };
 
+    class StarredRepositoryConnection {
+        public:
+        StarredRepositoryConnection() = default;
+        virtual ~StarredRepositoryConnection() = default;
+
+        private:
+        int64_t total_count;
+
+        public:
+        const int64_t & get_total_count() const { return total_count; }
+        int64_t & get_mutable_total_count() { return total_count; }
+        void set_total_count(const int64_t & value) { this->total_count = value; }
+    };
+
     class User {
         public:
         User() = default;
@@ -169,21 +225,21 @@ namespace quicktype {
 
         private:
         std::string login;
-        Connection starred_repositories;
-        RepositoryConnection repositories;
+        StarredRepositoryConnection starred_repositories;
+        UserRepositoryConnection repositories;
 
         public:
         const std::string & get_login() const { return login; }
         std::string & get_mutable_login() { return login; }
         void set_login(const std::string & value) { this->login = value; }
 
-        const Connection & get_starred_repositories() const { return starred_repositories; }
-        Connection & get_mutable_starred_repositories() { return starred_repositories; }
-        void set_starred_repositories(const Connection & value) { this->starred_repositories = value; }
+        const StarredRepositoryConnection & get_starred_repositories() const { return starred_repositories; }
+        StarredRepositoryConnection & get_mutable_starred_repositories() { return starred_repositories; }
+        void set_starred_repositories(const StarredRepositoryConnection & value) { this->starred_repositories = value; }
 
-        const RepositoryConnection & get_repositories() const { return repositories; }
-        RepositoryConnection & get_mutable_repositories() { return repositories; }
-        void set_repositories(const RepositoryConnection & value) { this->repositories = value; }
+        const UserRepositoryConnection & get_repositories() const { return repositories; }
+        UserRepositoryConnection & get_mutable_repositories() { return repositories; }
+        void set_repositories(const UserRepositoryConnection & value) { this->repositories = value; }
     };
 
     class Data {
@@ -234,8 +290,17 @@ namespace quicktype {
 }
 
 namespace quicktype {
-    void from_json(const json & j, Connection & x);
-    void to_json(json & j, const Connection & x);
+    void from_json(const json & j, RepositoryRepositoryConnection & x);
+    void to_json(json & j, const RepositoryRepositoryConnection & x);
+
+    void from_json(const json & j, IssueConnection & x);
+    void to_json(json & j, const IssueConnection & x);
+
+    void from_json(const json & j, StargazerConnection & x);
+    void to_json(json & j, const StargazerConnection & x);
+
+    void from_json(const json & j, UserConnection & x);
+    void to_json(json & j, const UserConnection & x);
 
     void from_json(const json & j, Repository & x);
     void to_json(json & j, const Repository & x);
@@ -243,8 +308,11 @@ namespace quicktype {
     void from_json(const json & j, RepositoryEdge & x);
     void to_json(json & j, const RepositoryEdge & x);
 
-    void from_json(const json & j, RepositoryConnection & x);
-    void to_json(json & j, const RepositoryConnection & x);
+    void from_json(const json & j, UserRepositoryConnection & x);
+    void to_json(json & j, const UserRepositoryConnection & x);
+
+    void from_json(const json & j, StarredRepositoryConnection & x);
+    void to_json(json & j, const StarredRepositoryConnection & x);
 
     void from_json(const json & j, User & x);
     void to_json(json & j, const User & x);
@@ -258,21 +326,48 @@ namespace quicktype {
     void from_json(const json & j, TopLevel & x);
     void to_json(json & j, const TopLevel & x);
 
-    inline void from_json(const json & j, Connection& x) {
+    inline void from_json(const json & j, RepositoryRepositoryConnection& x) {
+        x.set_total_count(j.at("totalCount").get<int64_t>());
+    }
+
+    inline void to_json(json & j, const RepositoryRepositoryConnection & x) {
+        j = json::object();
+        j["totalCount"] = x.get_total_count();
+    }
+
+    inline void from_json(const json & j, IssueConnection& x) {
+        x.set_total_count(j.at("totalCount").get<int64_t>());
+    }
+
+    inline void to_json(json & j, const IssueConnection & x) {
+        j = json::object();
+        j["totalCount"] = x.get_total_count();
+    }
+
+    inline void from_json(const json & j, StargazerConnection& x) {
         x.set_total_count(j.at("totalCount").get<int64_t>());
     }
 
-    inline void to_json(json & j, const Connection & x) {
+    inline void to_json(json & j, const StargazerConnection & x) {
+        j = json::object();
+        j["totalCount"] = x.get_total_count();
+    }
+
+    inline void from_json(const json & j, UserConnection& x) {
+        x.set_total_count(j.at("totalCount").get<int64_t>());
+    }
+
+    inline void to_json(json & j, const UserConnection & x) {
         j = json::object();
         j["totalCount"] = x.get_total_count();
     }
 
     inline void from_json(const json & j, Repository& x) {
         x.set_name(j.at("name").get<std::string>());
-        x.set_stargazers(j.at("stargazers").get<Connection>());
-        x.set_forks(j.at("forks").get<Connection>());
-        x.set_watchers(j.at("watchers").get<Connection>());
-        x.set_issues(j.at("issues").get<Connection>());
+        x.set_stargazers(j.at("stargazers").get<StargazerConnection>());
+        x.set_forks(j.at("forks").get<RepositoryRepositoryConnection>());
+        x.set_watchers(j.at("watchers").get<UserConnection>());
+        x.set_issues(j.at("issues").get<IssueConnection>());
     }
 
     inline void to_json(json & j, const Repository & x) {
@@ -293,19 +388,28 @@ namespace quicktype {
         j["node"] = x.get_node();
     }
 
-    inline void from_json(const json & j, RepositoryConnection& x) {
+    inline void from_json(const json & j, UserRepositoryConnection& x) {
         x.set_edges(get_stack_optional<std::vector<std::optional<RepositoryEdge>>>(j, "edges"));
     }
 
-    inline void to_json(json & j, const RepositoryConnection & x) {
+    inline void to_json(json & j, const UserRepositoryConnection & x) {
         j = json::object();
         j["edges"] = x.get_edges();
     }
 
+    inline void from_json(const json & j, StarredRepositoryConnection& x) {
+        x.set_total_count(j.at("totalCount").get<int64_t>());
+    }
+
+    inline void to_json(json & j, const StarredRepositoryConnection & x) {
+        j = json::object();
+        j["totalCount"] = x.get_total_count();
+    }
+
     inline void from_json(const json & j, User& x) {
         x.set_login(j.at("login").get<std::string>());
-        x.set_starred_repositories(j.at("starredRepositories").get<Connection>());
-        x.set_repositories(j.at("repositories").get<RepositoryConnection>());
+        x.set_starred_repositories(j.at("starredRepositories").get<StarredRepositoryConnection>());
+        x.set_repositories(j.at("repositories").get<UserRepositoryConnection>());
     }
 
     inline void to_json(json & j, const User & x) {
diff --git a/base/graphql-cplusplus/test/inputs/graphql/github9.graphql/default/quicktype.hpp b/head/graphql-cplusplus/test/inputs/graphql/github9.graphql/default/quicktype.hpp
index dffaf9c..f0f0e8d 100644
--- a/base/graphql-cplusplus/test/inputs/graphql/github9.graphql/default/quicktype.hpp
+++ b/head/graphql-cplusplus/test/inputs/graphql/github9.graphql/default/quicktype.hpp
@@ -104,6 +104,20 @@ namespace quicktype {
         void set_content(const ReactionContent & value) { this->content = value; }
     };
 
+    class ReactionGroup {
+        public:
+        ReactionGroup() = default;
+        virtual ~ReactionGroup() = default;
+
+        private:
+        ReactionContent content;
+
+        public:
+        const ReactionContent & get_content() const { return content; }
+        ReactionContent & get_mutable_content() { return content; }
+        void set_content(const ReactionContent & value) { this->content = value; }
+    };
+
     class Reactable {
         public:
         Reactable() = default;
@@ -111,15 +125,15 @@ namespace quicktype {
 
         private:
         bool viewer_can_react;
-        std::optional<std::vector<Reaction>> reaction_groups;
+        std::optional<std::vector<ReactionGroup>> reaction_groups;
 
         public:
         const bool & get_viewer_can_react() const { return viewer_can_react; }
         bool & get_mutable_viewer_can_react() { return viewer_can_react; }
         void set_viewer_can_react(const bool & value) { this->viewer_can_react = value; }
 
-        std::optional<std::vector<Reaction>> get_reaction_groups() const { return reaction_groups; }
-        void set_reaction_groups(std::optional<std::vector<Reaction>> value) { this->reaction_groups = value; }
+        std::optional<std::vector<ReactionGroup>> get_reaction_groups() const { return reaction_groups; }
+        void set_reaction_groups(std::optional<std::vector<ReactionGroup>> value) { this->reaction_groups = value; }
     };
 
     class AddReactionPayload {
@@ -195,6 +209,9 @@ namespace quicktype {
     void from_json(const json & j, Reaction & x);
     void to_json(json & j, const Reaction & x);
 
+    void from_json(const json & j, ReactionGroup & x);
+    void to_json(json & j, const ReactionGroup & x);
+
     void from_json(const json & j, Reactable & x);
     void to_json(json & j, const Reactable & x);
 
@@ -222,9 +239,18 @@ namespace quicktype {
         j["content"] = x.get_content();
     }
 
+    inline void from_json(const json & j, ReactionGroup& x) {
+        x.set_content(j.at("content").get<ReactionContent>());
+    }
+
+    inline void to_json(json & j, const ReactionGroup & x) {
+        j = json::object();
+        j["content"] = x.get_content();
+    }
+
     inline void from_json(const json & j, Reactable& x) {
         x.set_viewer_can_react(j.at("viewerCanReact").get<bool>());
-        x.set_reaction_groups(get_stack_optional<std::vector<Reaction>>(j, "reactionGroups"));
+        x.set_reaction_groups(get_stack_optional<std::vector<ReactionGroup>>(j, "reactionGroups"));
     }
 
     inline void to_json(json & j, const Reactable & x) {
diff --git a/head/graphql-cplusplus/test/inputs/graphql/separate-types1.graphql/default/quicktype.hpp b/head/graphql-cplusplus/test/inputs/graphql/separate-types1.graphql/default/quicktype.hpp
new file mode 100644
index 0000000..2dc83fb
--- /dev/null
+++ b/head/graphql-cplusplus/test/inputs/graphql/separate-types1.graphql/default/quicktype.hpp
@@ -0,0 +1,281 @@
+//  To parse this JSON data, first install
+//
+//      json.hpp  https://github.com/nlohmann/json
+//
+//  Then include this file, and then do
+//
+//     TopLevel data = nlohmann::json::parse(jsonString);
+
+#pragma once
+
+#include <optional>
+#include "json.hpp"
+
+#include <optional>
+#include <stdexcept>
+#include <regex>
+
+#ifndef NLOHMANN_OPT_HELPER
+#define NLOHMANN_OPT_HELPER
+namespace nlohmann {
+    template <typename T>
+    struct adl_serializer<std::shared_ptr<T>> {
+        static void to_json(json & j, const std::shared_ptr<T> & opt) {
+            if (!opt) j = nullptr; else j = *opt;
+        }
+
+        static std::shared_ptr<T> from_json(const json & j) {
+            if (j.is_null()) return std::shared_ptr<T>(); else return std::make_shared<T>(j.get<T>());
+        }
+    };
+    template <typename T>
+    struct adl_serializer<std::optional<T>> {
+        static void to_json(json & j, const std::optional<T> & opt) {
+            if (!opt) j = nullptr; else j = *opt;
+        }
+
+        static std::optional<T> from_json(const json & j) {
+            if (j.is_null()) return std::optional<T>(); else return std::make_optional<T>(j.get<T>());
+        }
+    };
+}
+#endif
+
+namespace quicktype {
+    using nlohmann::json;
+
+    #ifndef NLOHMANN_UNTYPED_quicktype_HELPER
+    #define NLOHMANN_UNTYPED_quicktype_HELPER
+    inline json get_untyped(const json & j, const char * property) {
+        if (j.find(property) != j.end()) {
+            return j.at(property).get<json>();
+        }
+        return json();
+    }
+
+    inline json get_untyped(const json & j, std::string property) {
+        return get_untyped(j, property.data());
+    }
+    #endif
+
+    #ifndef NLOHMANN_OPTIONAL_quicktype_HELPER
+    #define NLOHMANN_OPTIONAL_quicktype_HELPER
+    template <typename T>
+    inline std::shared_ptr<T> get_heap_optional(const json & j, const char * property) {
+        auto it = j.find(property);
+        if (it != j.end() && !it->is_null()) {
+            return j.at(property).get<std::shared_ptr<T>>();
+        }
+        return std::shared_ptr<T>();
+    }
+
+    template <typename T>
+    inline std::shared_ptr<T> get_heap_optional(const json & j, std::string property) {
+        return get_heap_optional<T>(j, property.data());
+    }
+    template <typename T>
+    inline std::optional<T> get_stack_optional(const json & j, const char * property) {
+        auto it = j.find(property);
+        if (it != j.end() && !it->is_null()) {
+            return j.at(property).get<std::optional<T>>();
+        }
+        return std::optional<T>();
+    }
+
+    template <typename T>
+    inline std::optional<T> get_stack_optional(const json & j, std::string property) {
+        return get_stack_optional<T>(j, property.data());
+    }
+    #endif
+
+    class ComponentRef {
+        public:
+        ComponentRef() = default;
+        virtual ~ComponentRef() = default;
+
+        private:
+        std::optional<std::string> id;
+
+        public:
+        std::optional<std::string> get_id() const { return id; }
+        void set_id(std::optional<std::string> value) { this->id = value; }
+    };
+
+    class GridConfig {
+        public:
+        GridConfig() = default;
+        virtual ~GridConfig() = default;
+
+        private:
+        std::optional<std::vector<std::optional<ComponentRef>>> items;
+
+        public:
+        std::optional<std::vector<std::optional<ComponentRef>>> get_items() const { return items; }
+        void set_items(std::optional<std::vector<std::optional<ComponentRef>>> value) { this->items = value; }
+    };
+
+    class GridProps {
+        public:
+        GridProps() = default;
+        virtual ~GridProps() = default;
+
+        private:
+        std::optional<std::vector<std::optional<ComponentRef>>> items;
+
+        public:
+        std::optional<std::vector<std::optional<ComponentRef>>> get_items() const { return items; }
+        void set_items(std::optional<std::vector<std::optional<ComponentRef>>> value) { this->items = value; }
+    };
+
+    class Grid {
+        public:
+        Grid() = default;
+        virtual ~Grid() = default;
+
+        private:
+        std::optional<GridConfig> config;
+        std::optional<GridProps> props;
+
+        public:
+        std::optional<GridConfig> get_config() const { return config; }
+        void set_config(std::optional<GridConfig> value) { this->config = value; }
+
+        std::optional<GridProps> get_props() const { return props; }
+        void set_props(std::optional<GridProps> value) { this->props = value; }
+    };
+
+    class Data {
+        public:
+        Data() = default;
+        virtual ~Data() = default;
+
+        private:
+        std::optional<Grid> grid;
+
+        public:
+        std::optional<Grid> get_grid() const { return grid; }
+        void set_grid(std::optional<Grid> value) { this->grid = value; }
+    };
+
+    class Error {
+        public:
+        Error() = default;
+        virtual ~Error() = default;
+
+        private:
+        std::string message;
+
+        public:
+        const std::string & get_message() const { return message; }
+        std::string & get_mutable_message() { return message; }
+        void set_message(const std::string & value) { this->message = value; }
+    };
+
+    class TopLevel {
+        public:
+        TopLevel() = default;
+        virtual ~TopLevel() = default;
+
+        private:
+        std::optional<Data> data;
+        std::optional<std::vector<Error>> errors;
+
+        public:
+        std::optional<Data> get_data() const { return data; }
+        void set_data(std::optional<Data> value) { this->data = value; }
+
+        const std::optional<std::vector<Error>> & get_errors() const { return errors; }
+        std::optional<std::vector<Error>> & get_mutable_errors() { return errors; }
+        void set_errors(const std::optional<std::vector<Error>> & value) { this->errors = value; }
+    };
+}
+
+namespace quicktype {
+    void from_json(const json & j, ComponentRef & x);
+    void to_json(json & j, const ComponentRef & x);
+
+    void from_json(const json & j, GridConfig & x);
+    void to_json(json & j, const GridConfig & x);
+
+    void from_json(const json & j, GridProps & x);
+    void to_json(json & j, const GridProps & x);
+
+    void from_json(const json & j, Grid & x);
+    void to_json(json & j, const Grid & x);
+
+    void from_json(const json & j, Data & x);
+    void to_json(json & j, const Data & x);
+
+    void from_json(const json & j, Error & x);
+    void to_json(json & j, const Error & x);
+
+    void from_json(const json & j, TopLevel & x);
+    void to_json(json & j, const TopLevel & x);
+
+    inline void from_json(const json & j, ComponentRef& x) {
+        x.set_id(get_stack_optional<std::string>(j, "id"));
+    }
+
+    inline void to_json(json & j, const ComponentRef & x) {
+        j = json::object();
+        j["id"] = x.get_id();
+    }
+
+    inline void from_json(const json & j, GridConfig& x) {
+        x.set_items(get_stack_optional<std::vector<std::optional<ComponentRef>>>(j, "items"));
+    }
+
+    inline void to_json(json & j, const GridConfig & x) {
+        j = json::object();
+        j["items"] = x.get_items();
+    }
+
+    inline void from_json(const json & j, GridProps& x) {
+        x.set_items(get_stack_optional<std::vector<std::optional<ComponentRef>>>(j, "items"));
+    }
+
+    inline void to_json(json & j, const GridProps & x) {
+        j = json::object();
+        j["items"] = x.get_items();
+    }
+
+    inline void from_json(const json & j, Grid& x) {
+        x.set_config(get_stack_optional<GridConfig>(j, "config"));
+        x.set_props(get_stack_optional<GridProps>(j, "props"));
+    }
+
+    inline void to_json(json & j, const Grid & x) {
+        j = json::object();
+        j["config"] = x.get_config();
+        j["props"] = x.get_props();
+    }
+
+    inline void from_json(const json & j, Data& x) {
+        x.set_grid(get_stack_optional<Grid>(j, "grid"));
+    }
+
+    inline void to_json(json & j, const Data & x) {
+        j = json::object();
+        j["grid"] = x.get_grid();
+    }
+
+    inline void from_json(const json & j, Error& x) {
+        x.set_message(j.at("message").get<std::string>());
+    }
+
+    inline void to_json(json & j, const Error & x) {
+        j = json::object();
+        j["message"] = x.get_message();
+    }
+
+    inline void from_json(const json & j, TopLevel& x) {
+        x.set_data(get_stack_optional<Data>(j, "data"));
+        x.set_errors(get_stack_optional<std::vector<Error>>(j, "errors"));
+    }
+
+    inline void to_json(json & j, const TopLevel & x) {
+        j = json::object();
+        j["data"] = x.get_data();
+        j["errors"] = x.get_errors();
+    }
+}
diff --git a/base/graphql-csharp/test/inputs/graphql/github7.graphql/default/QuickType.cs b/head/graphql-csharp/test/inputs/graphql/github7.graphql/default/QuickType.cs
index ef414db..eb22c3d 100644
--- a/base/graphql-csharp/test/inputs/graphql/github7.graphql/default/QuickType.cs
+++ b/head/graphql-csharp/test/inputs/graphql/github7.graphql/default/QuickType.cs
@@ -44,13 +44,13 @@ namespace QuickType
         public string Login { get; set; }
 
         [JsonProperty("starredRepositories", Required = Required.Always)]
-        public Connection StarredRepositories { get; set; }
+        public StarredRepositoryConnection StarredRepositories { get; set; }
 
         [JsonProperty("repositories", Required = Required.Always)]
-        public RepositoryConnection Repositories { get; set; }
+        public UserRepositoryConnection Repositories { get; set; }
     }
 
-    public partial class RepositoryConnection
+    public partial class UserRepositoryConnection
     {
         [JsonProperty("edges", Required = Required.AllowNull)]
         public RepositoryEdge?[]? Edges { get; set; }
@@ -68,19 +68,43 @@ namespace QuickType
         public string Name { get; set; }
 
         [JsonProperty("stargazers", Required = Required.Always)]
-        public Connection Stargazers { get; set; }
+        public StargazerConnection Stargazers { get; set; }
 
         [JsonProperty("forks", Required = Required.Always)]
-        public Connection Forks { get; set; }
+        public RepositoryRepositoryConnection Forks { get; set; }
 
         [JsonProperty("watchers", Required = Required.Always)]
-        public Connection Watchers { get; set; }
+        public UserConnection Watchers { get; set; }
 
         [JsonProperty("issues", Required = Required.Always)]
-        public Connection Issues { get; set; }
+        public IssueConnection Issues { get; set; }
     }
 
-    public partial class Connection
+    public partial class RepositoryRepositoryConnection
+    {
+        [JsonProperty("totalCount", Required = Required.Always)]
+        public long TotalCount { get; set; }
+    }
+
+    public partial class IssueConnection
+    {
+        [JsonProperty("totalCount", Required = Required.Always)]
+        public long TotalCount { get; set; }
+    }
+
+    public partial class StargazerConnection
+    {
+        [JsonProperty("totalCount", Required = Required.Always)]
+        public long TotalCount { get; set; }
+    }
+
+    public partial class UserConnection
+    {
+        [JsonProperty("totalCount", Required = Required.Always)]
+        public long TotalCount { get; set; }
+    }
+
+    public partial class StarredRepositoryConnection
     {
         [JsonProperty("totalCount", Required = Required.Always)]
         public long TotalCount { get; set; }
diff --git a/base/graphql-csharp/test/inputs/graphql/github9.graphql/default/QuickType.cs b/head/graphql-csharp/test/inputs/graphql/github9.graphql/default/QuickType.cs
index 6433940..96af3e6 100644
--- a/base/graphql-csharp/test/inputs/graphql/github9.graphql/default/QuickType.cs
+++ b/head/graphql-csharp/test/inputs/graphql/github9.graphql/default/QuickType.cs
@@ -62,7 +62,13 @@ namespace QuickType
         public bool ViewerCanReact { get; set; }
 
         [JsonProperty("reactionGroups", Required = Required.AllowNull)]
-        public Reaction[]? ReactionGroups { get; set; }
+        public ReactionGroup[]? ReactionGroups { get; set; }
+    }
+
+    public partial class ReactionGroup
+    {
+        [JsonProperty("content", Required = Required.Always)]
+        public ReactionContent Content { get; set; }
     }
 
     public partial class Error
diff --git a/head/graphql-csharp/test/inputs/graphql/separate-types1.graphql/default/QuickType.cs b/head/graphql-csharp/test/inputs/graphql/separate-types1.graphql/default/QuickType.cs
new file mode 100644
index 0000000..9fcc954
--- /dev/null
+++ b/head/graphql-csharp/test/inputs/graphql/separate-types1.graphql/default/QuickType.cs
@@ -0,0 +1,103 @@
+// <auto-generated />
+//
+// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
+//
+//    using QuickType;
+//
+//    var topLevel = TopLevel.FromJson(jsonString);
+#nullable enable
+#pragma warning disable CS8618
+#pragma warning disable CS8601
+#pragma warning disable CS8602
+#pragma warning disable CS8603
+#pragma warning disable CS8604
+#pragma warning disable CS8625
+#pragma warning disable CS8765
+
+namespace QuickType
+{
+    using System;
+    using System.Collections.Generic;
+
+    using System.Globalization;
+    using Newtonsoft.Json;
+    using Newtonsoft.Json.Converters;
+
+    public partial class TopLevel
+    {
+        [JsonProperty("data", Required = Required.AllowNull)]
+        public Data? Data { get; set; }
+
+        [JsonProperty("errors", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
+        public Error[]? Errors { get; set; }
+    }
+
+    public partial class Data
+    {
+        [JsonProperty("grid", Required = Required.AllowNull)]
+        public Grid? Grid { get; set; }
+    }
+
+    public partial class Grid
+    {
+        [JsonProperty("config", Required = Required.AllowNull)]
+        public GridConfig? Config { get; set; }
+
+        [JsonProperty("props", Required = Required.AllowNull)]
+        public GridProps? Props { get; set; }
+    }
+
+    public partial class GridConfig
+    {
+        [JsonProperty("items", Required = Required.AllowNull)]
+        public ComponentRef?[]? Items { get; set; }
+    }
+
+    public partial class ComponentRef
+    {
+        [JsonProperty("id", Required = Required.AllowNull)]
+        public string? Id { get; set; }
+    }
+
+    public partial class GridProps
+    {
+        [JsonProperty("items", Required = Required.AllowNull)]
+        public ComponentRef?[]? Items { get; set; }
+    }
+
+    public partial class Error
+    {
+        [JsonProperty("message", Required = Required.Always)]
+        public string Message { get; set; }
+    }
+
+    public partial class TopLevel
+    {
+        public static TopLevel FromJson(string json) => JsonConvert.DeserializeObject<TopLevel>(json, QuickType.Converter.Settings);
+    }
+
+    public static partial class Serialize
+    {
+        public static string ToJson(this TopLevel self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
+    }
+
+    internal static partial class Converter
+    {
+        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
+        {
+            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
+            DateParseHandling = DateParseHandling.None,
+            Converters =
+            {
+                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
+            },
+        };
+    }
+}
+#pragma warning restore CS8618
+#pragma warning restore CS8601
+#pragma warning restore CS8602
+#pragma warning restore CS8603
+#pragma warning restore CS8604
+#pragma warning restore CS8625
+#pragma warning restore CS8765
diff --git a/base/graphql-dart/test/inputs/graphql/github7.graphql/default/TopLevel.dart b/head/graphql-dart/test/inputs/graphql/github7.graphql/default/TopLevel.dart
index c82e0d5..1518860 100644
--- a/base/graphql-dart/test/inputs/graphql/github7.graphql/default/TopLevel.dart
+++ b/head/graphql-dart/test/inputs/graphql/github7.graphql/default/TopLevel.dart
@@ -46,8 +46,8 @@ class Data {
 
 class User {
     final String login;
-    final Connection starredRepositories;
-    final RepositoryConnection repositories;
+    final StarredRepositoryConnection starredRepositories;
+    final UserRepositoryConnection repositories;
 
     User({
         required this.login,
@@ -57,8 +57,8 @@ class User {
 
     factory User.fromJson(Map<String, dynamic> json) => User(
         login: json["login"],
-        starredRepositories: Connection.fromJson(json["starredRepositories"]),
-        repositories: RepositoryConnection.fromJson(json["repositories"]),
+        starredRepositories: StarredRepositoryConnection.fromJson(json["starredRepositories"]),
+        repositories: UserRepositoryConnection.fromJson(json["repositories"]),
     );
 
     Map<String, dynamic> toJson() => {
@@ -68,14 +68,14 @@ class User {
     };
 }
 
-class RepositoryConnection {
+class UserRepositoryConnection {
     final List<RepositoryEdge?>? edges;
 
-    RepositoryConnection({
+    UserRepositoryConnection({
         required this.edges,
     });
 
-    factory RepositoryConnection.fromJson(Map<String, dynamic> json) => RepositoryConnection(
+    factory UserRepositoryConnection.fromJson(Map<String, dynamic> json) => UserRepositoryConnection(
         edges: json["edges"] == null ? null : List<RepositoryEdge?>.from(json["edges"]!.map((x) => x == null ? null : RepositoryEdge.fromJson(x))),
     );
 
@@ -102,10 +102,10 @@ class RepositoryEdge {
 
 class Repository {
     final String name;
-    final Connection stargazers;
-    final Connection forks;
-    final Connection watchers;
-    final Connection issues;
+    final StargazerConnection stargazers;
+    final RepositoryRepositoryConnection forks;
+    final UserConnection watchers;
+    final IssueConnection issues;
 
     Repository({
         required this.name,
@@ -117,10 +117,10 @@ class Repository {
 
     factory Repository.fromJson(Map<String, dynamic> json) => Repository(
         name: json["name"],
-        stargazers: Connection.fromJson(json["stargazers"]),
-        forks: Connection.fromJson(json["forks"]),
-        watchers: Connection.fromJson(json["watchers"]),
-        issues: Connection.fromJson(json["issues"]),
+        stargazers: StargazerConnection.fromJson(json["stargazers"]),
+        forks: RepositoryRepositoryConnection.fromJson(json["forks"]),
+        watchers: UserConnection.fromJson(json["watchers"]),
+        issues: IssueConnection.fromJson(json["issues"]),
     );
 
     Map<String, dynamic> toJson() => {
@@ -132,14 +132,78 @@ class Repository {
     };
 }
 
-class Connection {
+class RepositoryRepositoryConnection {
     final int totalCount;
 
-    Connection({
+    RepositoryRepositoryConnection({
         required this.totalCount,
     });
 
-    factory Connection.fromJson(Map<String, dynamic> json) => Connection(
+    factory RepositoryRepositoryConnection.fromJson(Map<String, dynamic> json) => RepositoryRepositoryConnection(
+        totalCount: json["totalCount"],
+    );
+
+    Map<String, dynamic> toJson() => {
+        "totalCount": totalCount,
+    };
+}
+
+class IssueConnection {
+    final int totalCount;
+
+    IssueConnection({
+        required this.totalCount,
+    });
+
+    factory IssueConnection.fromJson(Map<String, dynamic> json) => IssueConnection(
+        totalCount: json["totalCount"],
+    );
+
+    Map<String, dynamic> toJson() => {
+        "totalCount": totalCount,
+    };
+}
+
+class StargazerConnection {
+    final int totalCount;
+
+    StargazerConnection({
+        required this.totalCount,
+    });
+
+    factory StargazerConnection.fromJson(Map<String, dynamic> json) => StargazerConnection(
+        totalCount: json["totalCount"],
+    );
+
+    Map<String, dynamic> toJson() => {
+        "totalCount": totalCount,
+    };
+}
+
+class UserConnection {
+    final int totalCount;
+
+    UserConnection({
+        required this.totalCount,
+    });
+
+    factory UserConnection.fromJson(Map<String, dynamic> json) => UserConnection(
+        totalCount: json["totalCount"],
+    );
+
+    Map<String, dynamic> toJson() => {
+        "totalCount": totalCount,
+    };
+}
+
+class StarredRepositoryConnection {
+    final int totalCount;
+
+    StarredRepositoryConnection({
+        required this.totalCount,
+    });
+
+    factory StarredRepositoryConnection.fromJson(Map<String, dynamic> json) => StarredRepositoryConnection(
         totalCount: json["totalCount"],
     );
 
diff --git a/base/graphql-dart/test/inputs/graphql/github9.graphql/default/TopLevel.dart b/head/graphql-dart/test/inputs/graphql/github9.graphql/default/TopLevel.dart
index 33dd864..6f9c556 100644
--- a/base/graphql-dart/test/inputs/graphql/github9.graphql/default/TopLevel.dart
+++ b/head/graphql-dart/test/inputs/graphql/github9.graphql/default/TopLevel.dart
@@ -104,7 +104,7 @@ final reactionContentValues = EnumValues({
 
 class Reactable {
     final bool viewerCanReact;
-    final List<Reaction>? reactionGroups;
+    final List<ReactionGroup>? reactionGroups;
 
     Reactable({
         required this.viewerCanReact,
@@ -113,7 +113,7 @@ class Reactable {
 
     factory Reactable.fromJson(Map<String, dynamic> json) => Reactable(
         viewerCanReact: json["viewerCanReact"],
-        reactionGroups: json["reactionGroups"] == null ? null : List<Reaction>.from(json["reactionGroups"]!.map((x) => Reaction.fromJson(x))),
+        reactionGroups: json["reactionGroups"] == null ? null : List<ReactionGroup>.from(json["reactionGroups"]!.map((x) => ReactionGroup.fromJson(x))),
     );
 
     Map<String, dynamic> toJson() => {
@@ -122,6 +122,22 @@ class Reactable {
     };
 }
 
+class ReactionGroup {
+    final ReactionContent content;
+
+    ReactionGroup({
+        required this.content,
+    });
+
+    factory ReactionGroup.fromJson(Map<String, dynamic> json) => ReactionGroup(
+        content: reactionContentValues.map[json["content"]]!,
+    );
+
+    Map<String, dynamic> toJson() => {
+        "content": reactionContentValues.reverse[content],
+    };
+}
+
 class Error {
     final String message;
 
diff --git a/head/graphql-dart/test/inputs/graphql/separate-types1.graphql/default/TopLevel.dart b/head/graphql-dart/test/inputs/graphql/separate-types1.graphql/default/TopLevel.dart
new file mode 100644
index 0000000..1902eb5
--- /dev/null
+++ b/head/graphql-dart/test/inputs/graphql/separate-types1.graphql/default/TopLevel.dart
@@ -0,0 +1,129 @@
+// To parse this JSON data, do
+//
+//     final topLevel = topLevelFromJson(jsonString);
+
+import 'dart:convert';
+
+TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
+
+String topLevelToJson(TopLevel data) => json.encode(data.toJson());
+
+class TopLevel {
+    final Data? data;
+    final List<Error>? errors;
+
+    TopLevel({
+        required this.data,
+        this.errors,
+    });
+
+    factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
+        data: json["data"] == null ? null : Data.fromJson(json["data"]),
+        errors: json["errors"] == null ? null : List<Error>.from(json["errors"]!.map((x) => Error.fromJson(x))),
+    );
+
+    Map<String, dynamic> toJson() => {
+        "data": data?.toJson(),
+        "errors": errors == null ? null : List<dynamic>.from(errors!.map((x) => x.toJson())),
+    };
+}
+
+class Data {
+    final Grid? grid;
+
+    Data({
+        required this.grid,
+    });
+
+    factory Data.fromJson(Map<String, dynamic> json) => Data(
+        grid: json["grid"] == null ? null : Grid.fromJson(json["grid"]),
+    );
+
+    Map<String, dynamic> toJson() => {
+        "grid": grid?.toJson(),
+    };
+}
+
+class Grid {
+    final GridConfig? config;
+    final GridProps? props;
+
+    Grid({
+        required this.config,
+        required this.props,
+    });
+
+    factory Grid.fromJson(Map<String, dynamic> json) => Grid(
+        config: json["config"] == null ? null : GridConfig.fromJson(json["config"]),
+        props: json["props"] == null ? null : GridProps.fromJson(json["props"]),
+    );
+
+    Map<String, dynamic> toJson() => {
+        "config": config?.toJson(),
+        "props": props?.toJson(),
+    };
+}
+
+class GridConfig {
+    final List<ComponentRef?>? items;
+
+    GridConfig({
+        required this.items,
+    });
+
+    factory GridConfig.fromJson(Map<String, dynamic> json) => GridConfig(
+        items: json["items"] == null ? null : List<ComponentRef?>.from(json["items"]!.map((x) => x == null ? null : ComponentRef.fromJson(x))),
+    );
+
+    Map<String, dynamic> toJson() => {
+        "items": items == null ? null : List<dynamic>.from(items!.map((x) => x?.toJson())),
+    };
+}
+
+class ComponentRef {
+    final String? id;
+
+    ComponentRef({
+        required this.id,
+    });
+
+    factory ComponentRef.fromJson(Map<String, dynamic> json) => ComponentRef(
+        id: json["id"],
+    );
+
+    Map<String, dynamic> toJson() => {
+        "id": id,
+    };
+}
+
+class GridProps {
+    final List<ComponentRef?>? items;
+
+    GridProps({
+        required this.items,
+    });
+
+    factory GridProps.fromJson(Map<String, dynamic> json) => GridProps(
+        items: json["items"] == null ? null : List<ComponentRef?>.from(json["items"]!.map((x) => x == null ? null : ComponentRef.fromJson(x))),
+    );
+
+    Map<String, dynamic> toJson() => {
+        "items": items == null ? null : List<dynamic>.from(items!.map((x) => x?.toJson())),
+    };
+}
+
+class Error {
+    final String message;
+
+    Error({
+        required this.message,
+    });
+
+    factory Error.fromJson(Map<String, dynamic> json) => Error(
+        message: json["message"],
+    );
+
+    Map<String, dynamic> toJson() => {
+        "message": message,
+    };
+}
diff --git a/base/graphql-elixir/test/inputs/graphql/github7.graphql/default/QuickType.ex b/head/graphql-elixir/test/inputs/graphql/github7.graphql/default/QuickType.ex
index 9d7f346..a749743 100644
--- a/base/graphql-elixir/test/inputs/graphql/github7.graphql/default/QuickType.ex
+++ b/head/graphql-elixir/test/inputs/graphql/github7.graphql/default/QuickType.ex
@@ -5,7 +5,7 @@
 # Decode a JSON string: TopLevel.from_json(data)
 # Encode into a JSON string: TopLevel.to_json(struct)
 
-defmodule Connection do
+defmodule RepositoryRepositoryConnection do
   @enforce_keys [:total_count]
   defstruct [:total_count]
 
@@ -14,7 +14,106 @@ defmodule Connection do
         }
 
   def from_map(m) do
-    %Connection{
+    %RepositoryRepositoryConnection{
+      total_count: m["totalCount"],
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "totalCount" => struct.total_count,
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule IssueConnection do
+  @enforce_keys [:total_count]
+  defstruct [:total_count]
+
+  @type t :: %__MODULE__{
+          total_count: integer()
+        }
+
+  def from_map(m) do
+    %IssueConnection{
+      total_count: m["totalCount"],
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "totalCount" => struct.total_count,
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule StargazerConnection do
+  @enforce_keys [:total_count]
+  defstruct [:total_count]
+
+  @type t :: %__MODULE__{
+          total_count: integer()
+        }
+
+  def from_map(m) do
+    %StargazerConnection{
+      total_count: m["totalCount"],
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "totalCount" => struct.total_count,
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule UserConnection do
+  @enforce_keys [:total_count]
+  defstruct [:total_count]
+
+  @type t :: %__MODULE__{
+          total_count: integer()
+        }
+
+  def from_map(m) do
+    %UserConnection{
       total_count: m["totalCount"],
     }
   end
@@ -44,19 +143,19 @@ defmodule Repository do
 
   @type t :: %__MODULE__{
           name: String.t(),
-          stargazers: Connection.t(),
-          forks: Connection.t(),
-          watchers: Connection.t(),
-          issues: Connection.t()
+          stargazers: StargazerConnection.t(),
+          forks: RepositoryRepositoryConnection.t(),
+          watchers: UserConnection.t(),
+          issues: IssueConnection.t()
         }
 
   def from_map(m) do
     %Repository{
       name: m["name"],
-      stargazers: Connection.from_map(m["stargazers"]),
-      forks: Connection.from_map(m["forks"]),
-      watchers: Connection.from_map(m["watchers"]),
-      issues: Connection.from_map(m["issues"]),
+      stargazers: StargazerConnection.from_map(m["stargazers"]),
+      forks: RepositoryRepositoryConnection.from_map(m["forks"]),
+      watchers: UserConnection.from_map(m["watchers"]),
+      issues: IssueConnection.from_map(m["issues"]),
     }
   end
 
@@ -69,10 +168,10 @@ defmodule Repository do
   def to_map(struct) do
     %{
       "name" => struct.name,
-      "stargazers" => Connection.to_map(struct.stargazers),
-      "forks" => Connection.to_map(struct.forks),
-      "watchers" => Connection.to_map(struct.watchers),
-      "issues" => Connection.to_map(struct.issues),
+      "stargazers" => StargazerConnection.to_map(struct.stargazers),
+      "forks" => RepositoryRepositoryConnection.to_map(struct.forks),
+      "watchers" => UserConnection.to_map(struct.watchers),
+      "issues" => IssueConnection.to_map(struct.issues),
     }
   end
 
@@ -116,7 +215,7 @@ defmodule RepositoryEdge do
   end
 end
 
-defmodule RepositoryConnection do
+defmodule UserRepositoryConnection do
   @enforce_keys [:edges]
   defstruct [:edges]
 
@@ -126,14 +225,14 @@ defmodule RepositoryConnection do
 
   def decode_edges_element(%{"node" => _,} = value), do: RepositoryEdge.from_map(value)
   def decode_edges_element(value) when is_nil(value), do: value
-  def decode_edges_element(_), do: {:error, "Unexpected type when decoding RepositoryConnection.edges"}
+  def decode_edges_element(_), do: {:error, "Unexpected type when decoding UserRepositoryConnection.edges"}
 
   def encode_edges_element(%RepositoryEdge{} = value), do: RepositoryEdge.to_map(value)
   def encode_edges_element(value) when is_nil(value), do: value
-  def encode_edges_element(_), do: {:error, "Unexpected type when encoding RepositoryConnection.edges"}
+  def encode_edges_element(_), do: {:error, "Unexpected type when encoding UserRepositoryConnection.edges"}
 
   def from_map(m) do
-    %RepositoryConnection{
+    %UserRepositoryConnection{
       edges: m["edges"] && Enum.map(m["edges"], &decode_edges_element/1),
     }
   end
@@ -157,21 +256,54 @@ defmodule RepositoryConnection do
   end
 end
 
+defmodule StarredRepositoryConnection do
+  @enforce_keys [:total_count]
+  defstruct [:total_count]
+
+  @type t :: %__MODULE__{
+          total_count: integer()
+        }
+
+  def from_map(m) do
+    %StarredRepositoryConnection{
+      total_count: m["totalCount"],
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "totalCount" => struct.total_count,
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
 defmodule User do
   @enforce_keys [:login, :starred_repositories, :repositories]
   defstruct [:login, :starred_repositories, :repositories]
 
   @type t :: %__MODULE__{
           login: String.t(),
-          starred_repositories: Connection.t(),
-          repositories: RepositoryConnection.t()
+          starred_repositories: StarredRepositoryConnection.t(),
+          repositories: UserRepositoryConnection.t()
         }
 
   def from_map(m) do
     %User{
       login: m["login"],
-      starred_repositories: Connection.from_map(m["starredRepositories"]),
-      repositories: RepositoryConnection.from_map(m["repositories"]),
+      starred_repositories: StarredRepositoryConnection.from_map(m["starredRepositories"]),
+      repositories: UserRepositoryConnection.from_map(m["repositories"]),
     }
   end
 
@@ -184,8 +316,8 @@ defmodule User do
   def to_map(struct) do
     %{
       "login" => struct.login,
-      "starredRepositories" => Connection.to_map(struct.starred_repositories),
-      "repositories" => RepositoryConnection.to_map(struct.repositories),
+      "starredRepositories" => StarredRepositoryConnection.to_map(struct.starred_repositories),
+      "repositories" => UserRepositoryConnection.to_map(struct.repositories),
     }
   end
 
diff --git a/base/graphql-elixir/test/inputs/graphql/github9.graphql/default/QuickType.ex b/head/graphql-elixir/test/inputs/graphql/github9.graphql/default/QuickType.ex
index ee70a8b..f3c80a6 100644
--- a/base/graphql-elixir/test/inputs/graphql/github9.graphql/default/QuickType.ex
+++ b/head/graphql-elixir/test/inputs/graphql/github9.graphql/default/QuickType.ex
@@ -88,19 +88,52 @@ defmodule Reaction do
   end
 end
 
+defmodule ReactionGroup do
+  @enforce_keys [:content]
+  defstruct [:content]
+
+  @type t :: %__MODULE__{
+          content: ReactionContent.t()
+        }
+
+  def from_map(m) do
+    %ReactionGroup{
+      content: ReactionContent.decode(m["content"]),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "content" => ReactionContent.encode(struct.content),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
 defmodule Reactable do
   @enforce_keys [:viewer_can_react, :reaction_groups]
   defstruct [:viewer_can_react, :reaction_groups]
 
   @type t :: %__MODULE__{
           viewer_can_react: boolean(),
-          reaction_groups: [Reaction.t()] | nil
+          reaction_groups: [ReactionGroup.t()] | nil
         }
 
   def from_map(m) do
     %Reactable{
       viewer_can_react: m["viewerCanReact"],
-      reaction_groups: m["reactionGroups"] && Enum.map(m["reactionGroups"], &Reaction.from_map/1),
+      reaction_groups: m["reactionGroups"] && Enum.map(m["reactionGroups"], &ReactionGroup.from_map/1),
     }
   end
 
@@ -113,7 +146,7 @@ defmodule Reactable do
   def to_map(struct) do
     %{
       "viewerCanReact" => struct.viewer_can_react,
-      "reactionGroups" => struct.reaction_groups && Enum.map(struct.reaction_groups, &Reaction.to_map/1),
+      "reactionGroups" => struct.reaction_groups && Enum.map(struct.reaction_groups, &ReactionGroup.to_map/1),
     }
   end
 
diff --git a/head/graphql-elixir/test/inputs/graphql/separate-types1.graphql/default/QuickType.ex b/head/graphql-elixir/test/inputs/graphql/separate-types1.graphql/default/QuickType.ex
new file mode 100644
index 0000000..9deab55
--- /dev/null
+++ b/head/graphql-elixir/test/inputs/graphql/separate-types1.graphql/default/QuickType.ex
@@ -0,0 +1,259 @@
+# This file was autogenerated using quicktype https://github.com/quicktype/quicktype
+#
+# Add Jason to your mix.exs
+#
+# Decode a JSON string: TopLevel.from_json(data)
+# Encode into a JSON string: TopLevel.to_json(struct)
+
+defmodule ComponentRef do
+  @enforce_keys [:id]
+  defstruct [:id]
+
+  @type t :: %__MODULE__{
+          id: nil | String.t()
+        }
+
+  def from_map(m) do
+    %ComponentRef{
+      id: m["id"],
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "id" => struct.id,
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule GridConfig do
+  @enforce_keys [:items]
+  defstruct [:items]
+
+  @type t :: %__MODULE__{
+          items: [ComponentRef.t() | nil] | nil
+        }
+
+  def decode_items_element(%{"id" => _,} = value), do: ComponentRef.from_map(value)
+  def decode_items_element(value) when is_nil(value), do: value
+  def decode_items_element(_), do: {:error, "Unexpected type when decoding GridConfig.items"}
+
+  def encode_items_element(%ComponentRef{} = value), do: ComponentRef.to_map(value)
+  def encode_items_element(value) when is_nil(value), do: value
+  def encode_items_element(_), do: {:error, "Unexpected type when encoding GridConfig.items"}
+
+  def from_map(m) do
+    %GridConfig{
+      items: m["items"] && Enum.map(m["items"], &decode_items_element/1),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "items" => struct.items && Enum.map(struct.items, &encode_items_element/1),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule GridProps do
+  @enforce_keys [:items]
+  defstruct [:items]
+
+  @type t :: %__MODULE__{
+          items: [ComponentRef.t() | nil] | nil
+        }
+
+  def decode_items_element(%{"id" => _,} = value), do: ComponentRef.from_map(value)
+  def decode_items_element(value) when is_nil(value), do: value
+  def decode_items_element(_), do: {:error, "Unexpected type when decoding GridProps.items"}
+
+  def encode_items_element(%ComponentRef{} = value), do: ComponentRef.to_map(value)
+  def encode_items_element(value) when is_nil(value), do: value
+  def encode_items_element(_), do: {:error, "Unexpected type when encoding GridProps.items"}
+
+  def from_map(m) do
+    %GridProps{
+      items: m["items"] && Enum.map(m["items"], &decode_items_element/1),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "items" => struct.items && Enum.map(struct.items, &encode_items_element/1),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule Grid do
+  @enforce_keys [:config, :props]
+  defstruct [:config, :props]
+
+  @type t :: %__MODULE__{
+          config: GridConfig.t() | nil,
+          props: GridProps.t() | nil
+        }
+
+  def from_map(m) do
+    %Grid{
+      config: m["config"] && GridConfig.from_map(m["config"]),
+      props: m["props"] && GridProps.from_map(m["props"]),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "config" => struct.config && GridConfig.to_map(struct.config),
+      "props" => struct.props && GridProps.to_map(struct.props),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule Data do
+  @enforce_keys [:grid]
+  defstruct [:grid]
+
+  @type t :: %__MODULE__{
+          grid: Grid.t() | nil
+        }
+
+  def from_map(m) do
+    %Data{
+      grid: m["grid"] && Grid.from_map(m["grid"]),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "grid" => struct.grid && Grid.to_map(struct.grid),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule Error do
+  @enforce_keys [:message]
+  defstruct [:message]
+
+  @type t :: %__MODULE__{
+          message: String.t()
+        }
+
+  def from_map(m) do
+    %Error{
+      message: m["message"],
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "message" => struct.message,
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule TopLevel do
+  @enforce_keys [:data]
+  defstruct [:data, :errors]
+
+  @type t :: %__MODULE__{
+          data: Data.t() | nil,
+          errors: [Error.t()] | nil
+        }
+
+  def from_map(m) do
+    %TopLevel{
+      data: m["data"] && Data.from_map(m["data"]),
+      errors: m["errors"] && Enum.map(m["errors"], &Error.from_map/1),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "data" => struct.data && Data.to_map(struct.data),
+      "errors" => struct.errors && Enum.map(struct.errors, &Error.to_map/1),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
diff --git a/base/graphql-flow/test/inputs/graphql/github7.graphql/default/TopLevel.js b/head/graphql-flow/test/inputs/graphql/github7.graphql/default/TopLevel.js
index 97c585b..69c2a00 100644
--- a/base/graphql-flow/test/inputs/graphql/github7.graphql/default/TopLevel.js
+++ b/head/graphql-flow/test/inputs/graphql/github7.graphql/default/TopLevel.js
@@ -20,11 +20,11 @@ export type Data = {
 
 export type User = {
     login:               string;
-    starredRepositories: Connection;
-    repositories:        RepositoryConnection;
+    starredRepositories: StarredRepositoryConnection;
+    repositories:        UserRepositoryConnection;
 };
 
-export type RepositoryConnection = {
+export type UserRepositoryConnection = {
     edges: (RepositoryEdge | null)[] | null;
 };
 
@@ -34,13 +34,29 @@ export type RepositoryEdge = {
 
 export type Repository = {
     name:       string;
-    stargazers: Connection;
-    forks:      Connection;
-    watchers:   Connection;
-    issues:     Connection;
+    stargazers: StargazerConnection;
+    forks:      RepositoryRepositoryConnection;
+    watchers:   UserConnection;
+    issues:     IssueConnection;
 };
 
-export type Connection = {
+export type RepositoryRepositoryConnection = {
+    totalCount: number;
+};
+
+export type IssueConnection = {
+    totalCount: number;
+};
+
+export type StargazerConnection = {
+    totalCount: number;
+};
+
+export type UserConnection = {
+    totalCount: number;
+};
+
+export type StarredRepositoryConnection = {
     totalCount: number;
 };
 
@@ -221,10 +237,10 @@ const typeMap: any = {
     ], false),
     "User": o([
         { json: "login", js: "login", typ: "" },
-        { json: "starredRepositories", js: "starredRepositories", typ: r("Connection") },
-        { json: "repositories", js: "repositories", typ: r("RepositoryConnection") },
+        { json: "starredRepositories", js: "starredRepositories", typ: r("StarredRepositoryConnection") },
+        { json: "repositories", js: "repositories", typ: r("UserRepositoryConnection") },
     ], false),
-    "RepositoryConnection": o([
+    "UserRepositoryConnection": o([
         { json: "edges", js: "edges", typ: u(a(u(r("RepositoryEdge"), null)), null) },
     ], false),
     "RepositoryEdge": o([
@@ -232,12 +248,24 @@ const typeMap: any = {
     ], false),
     "Repository": o([
         { json: "name", js: "name", typ: "" },
-        { json: "stargazers", js: "stargazers", typ: r("Connection") },
-        { json: "forks", js: "forks", typ: r("Connection") },
-        { json: "watchers", js: "watchers", typ: r("Connection") },
-        { json: "issues", js: "issues", typ: r("Connection") },
+        { json: "stargazers", js: "stargazers", typ: r("StargazerConnection") },
+        { json: "forks", js: "forks", typ: r("RepositoryRepositoryConnection") },
+        { json: "watchers", js: "watchers", typ: r("UserConnection") },
+        { json: "issues", js: "issues", typ: r("IssueConnection") },
+    ], false),
+    "RepositoryRepositoryConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "IssueConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "StargazerConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "UserConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
     ], false),
-    "Connection": o([
+    "StarredRepositoryConnection": o([
         { json: "totalCount", js: "totalCount", typ: 0 },
     ], false),
     "ErrorElement": o([
diff --git a/base/graphql-flow/test/inputs/graphql/github9.graphql/default/TopLevel.js b/head/graphql-flow/test/inputs/graphql/github9.graphql/default/TopLevel.js
index 39662bf..aa9fe04 100644
--- a/base/graphql-flow/test/inputs/graphql/github9.graphql/default/TopLevel.js
+++ b/head/graphql-flow/test/inputs/graphql/github9.graphql/default/TopLevel.js
@@ -38,7 +38,11 @@ export type ReactionContent =
 
 export type Reactable = {
     viewerCanReact: boolean;
-    reactionGroups: Reaction[] | null;
+    reactionGroups: ReactionGroup[] | null;
+};
+
+export type ReactionGroup = {
+    content: ReactionContent;
 };
 
 export type ErrorElement = {
@@ -226,7 +230,10 @@ const typeMap: any = {
     ], false),
     "Reactable": o([
         { json: "viewerCanReact", js: "viewerCanReact", typ: true },
-        { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("Reaction")), null) },
+        { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("ReactionGroup")), null) },
+    ], false),
+    "ReactionGroup": o([
+        { json: "content", js: "content", typ: r("ReactionContent") },
     ], false),
     "ErrorElement": o([
         { json: "message", js: "message", typ: "" },
diff --git a/head/graphql-flow/test/inputs/graphql/separate-types1.graphql/default/TopLevel.js b/head/graphql-flow/test/inputs/graphql/separate-types1.graphql/default/TopLevel.js
new file mode 100644
index 0000000..9d69463
--- /dev/null
+++ b/head/graphql-flow/test/inputs/graphql/separate-types1.graphql/default/TopLevel.js
@@ -0,0 +1,234 @@
+// @flow
+
+// To parse this data:
+//
+//   const Convert = require("./TopLevel");
+//
+//   const topLevel = Convert.toTopLevel(json);
+//
+// These functions will throw an error if the JSON doesn't
+// match the expected interface, even if the JSON is valid.
+
+export type TopLevel = {
+    data:    Data | null;
+    errors?: ErrorElement[];
+};
+
+export type Data = {
+    grid: Grid | null;
+};
+
+export type Grid = {
+    config: GridConfig | null;
+    props:  GridProps | null;
+};
+
+export type GridConfig = {
+    items: (ComponentRef | null)[] | null;
+};
+
+export type ComponentRef = {
+    id: null | string;
+};
+
+export type GridProps = {
+    items: (ComponentRef | null)[] | null;
+};
+
+export type ErrorElement = {
+    message: string;
+};
+
+// Converts JSON strings to/from your types
+// and asserts the results of JSON.parse at runtime
+function toTopLevel(json: string): TopLevel {
+    return cast(JSON.parse(json), r("TopLevel"));
+}
+
+function topLevelToJson(value: TopLevel): string {
+    return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
+}
+
+function invalidValue(typ: any, val: any, key: any, parent: any = '') {
+    const prettyTyp = prettyTypeName(typ);
+    const parentText = parent ? ` on ${parent}` : '';
+    const keyText = key ? ` for key "${key}"` : '';
+    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
+}
+
+function prettyTypeName(typ: any): string {
+    if (Array.isArray(typ)) {
+        if (typ.length === 2 && typ[0] === undefined) {
+            return `an optional ${prettyTypeName(typ[1])}`;
+        } else {
+            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
+        }
+    } else if (typeof typ === "object" && typ.literal !== undefined) {
+        return typ.literal;
+    } else {
+        return typeof typ;
+    }
+}
+
+function jsonToJSProps(typ: any): any {
+    if (typ.jsonToJS === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
+        typ.jsonToJS = map;
+    }
+    return typ.jsonToJS;
+}
+
+function jsToJSONProps(typ: any): any {
+    if (typ.jsToJSON === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
+        typ.jsToJSON = map;
+    }
+    return typ.jsToJSON;
+}
+
+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
+    function transformPrimitive(typ: string, val: any): any {
+        if (typeof typ === typeof val) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+
+    function transformUnion(typs: any[], val: any): any {
+        // val must validate against one typ in typs
+        const l = typs.length;
+        for (let i = 0; i < l; i++) {
+            const typ = typs[i];
+            try {
+                return transform(val, typ, getProps);
+            } catch (_) {}
+        }
+        return invalidValue(typs, val, key, parent);
+    }
+
+    function transformEnum(cases: string[], val: any): any {
+        if (cases.indexOf(val) !== -1) return val;
+        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
+    }
+
+    function transformArray(typ: any, val: any): any {
+        // val must be an array with no invalid elements
+        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
+        return val.map(el => transform(el, typ, getProps));
+    }
+
+    function transformDate(val: any): any {
+        if (val === null) {
+            return null;
+        }
+        const d = new Date(val);
+        if (isNaN(d.valueOf())) {
+            return invalidValue(l("Date"), val, key, parent);
+        }
+        return d;
+    }
+
+    function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
+        if (val === null || typeof val !== "object" || Array.isArray(val)) {
+            return invalidValue(l(ref || "object"), val, key, parent);
+        }
+        const result: any = {};
+        Object.getOwnPropertyNames(props).forEach(key => {
+            const prop = props[key];
+            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
+            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
+        });
+        Object.getOwnPropertyNames(val).forEach(key => {
+            if (!Object.prototype.hasOwnProperty.call(props, key)) {
+                result[key] = transform(val[key], additional, getProps, key, ref);
+            }
+        });
+        return result;
+    }
+
+    if (typ === "any") return val;
+    if (typ === null) {
+        if (val === null) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+    if (typ === false) return invalidValue(typ, val, key, parent);
+    let ref: any = undefined;
+    while (typeof typ === "object" && typ.ref !== undefined) {
+        ref = typ.ref;
+        typ = typeMap[typ.ref];
+    }
+    if (Array.isArray(typ)) return transformEnum(typ, val);
+    if (typeof typ === "object") {
+        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
+            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
+            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
+            : invalidValue(typ, val, key, parent);
+    }
+    // Numbers can be parsed by Date but shouldn't be.
+    if (typ === Date && typeof val !== "number") return transformDate(val);
+    return transformPrimitive(typ, val);
+}
+
+function cast<T>(val: any, typ: any): T {
+    return transform(val, typ, jsonToJSProps);
+}
+
+function uncast<T>(val: T, typ: any): any {
+    return transform(val, typ, jsToJSONProps);
+}
+
+function l(typ: any) {
+    return { literal: typ };
+}
+
+function a(typ: any) {
+    return { arrayItems: typ };
+}
+
+function u(...typs: any[]) {
+    return { unionMembers: typs };
+}
+
+function o(props: any[], additional: any) {
+    return { props, additional };
+}
+
+function m(additional: any) {
+    const props: any[] = [];
+    return { props, additional };
+}
+
+function r(name: string) {
+    return { ref: name };
+}
+
+const typeMap: any = {
+    "TopLevel": o([
+        { json: "data", js: "data", typ: u(r("Data"), null) },
+        { json: "errors", js: "errors", typ: u(undefined, a(r("ErrorElement"))) },
+    ], false),
+    "Data": o([
+        { json: "grid", js: "grid", typ: u(r("Grid"), null) },
+    ], false),
+    "Grid": o([
+        { json: "config", js: "config", typ: u(r("GridConfig"), null) },
+        { json: "props", js: "props", typ: u(r("GridProps"), null) },
+    ], false),
+    "GridConfig": o([
+        { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
+    ], false),
+    "ComponentRef": o([
+        { json: "id", js: "id", typ: u(null, "") },
+    ], false),
+    "GridProps": o([
+        { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
+    ], false),
+    "ErrorElement": o([
+        { json: "message", js: "message", typ: "" },
+    ], false),
+};
+
+module.exports = {
+    "topLevelToJson": topLevelToJson,
+    "toTopLevel": toTopLevel,
+};
diff --git a/base/graphql-golang/test/inputs/graphql/github7.graphql/default/quicktype.go b/head/graphql-golang/test/inputs/graphql/github7.graphql/default/quicktype.go
index 6211202..ffd0be1 100644
--- a/base/graphql-golang/test/inputs/graphql/github7.graphql/default/quicktype.go
+++ b/head/graphql-golang/test/inputs/graphql/github7.graphql/default/quicktype.go
@@ -28,12 +28,12 @@ type Data struct {
 }
 
 type User struct {
-	Login               string               `json:"login"`
-	StarredRepositories Connection           `json:"starredRepositories"`
-	Repositories        RepositoryConnection `json:"repositories"`
+	Login               string                      `json:"login"`
+	StarredRepositories StarredRepositoryConnection `json:"starredRepositories"`
+	Repositories        UserRepositoryConnection    `json:"repositories"`
 }
 
-type RepositoryConnection struct {
+type UserRepositoryConnection struct {
 	Edges []*RepositoryEdge `json:"edges"`
 }
 
@@ -42,14 +42,30 @@ type RepositoryEdge struct {
 }
 
 type Repository struct {
-	Name       string     `json:"name"`
-	Stargazers Connection `json:"stargazers"`
-	Forks      Connection `json:"forks"`
-	Watchers   Connection `json:"watchers"`
-	Issues     Connection `json:"issues"`
+	Name       string                         `json:"name"`
+	Stargazers StargazerConnection            `json:"stargazers"`
+	Forks      RepositoryRepositoryConnection `json:"forks"`
+	Watchers   UserConnection                 `json:"watchers"`
+	Issues     IssueConnection                `json:"issues"`
 }
 
-type Connection struct {
+type RepositoryRepositoryConnection struct {
+	TotalCount int64 `json:"totalCount"`
+}
+
+type IssueConnection struct {
+	TotalCount int64 `json:"totalCount"`
+}
+
+type StargazerConnection struct {
+	TotalCount int64 `json:"totalCount"`
+}
+
+type UserConnection struct {
+	TotalCount int64 `json:"totalCount"`
+}
+
+type StarredRepositoryConnection struct {
 	TotalCount int64 `json:"totalCount"`
 }
 
diff --git a/base/graphql-golang/test/inputs/graphql/github9.graphql/default/quicktype.go b/head/graphql-golang/test/inputs/graphql/github9.graphql/default/quicktype.go
index dc48f6c..d09cc30 100644
--- a/base/graphql-golang/test/inputs/graphql/github9.graphql/default/quicktype.go
+++ b/head/graphql-golang/test/inputs/graphql/github9.graphql/default/quicktype.go
@@ -38,8 +38,12 @@ type Reaction struct {
 }
 
 type Reactable struct {
-	ViewerCanReact bool       `json:"viewerCanReact"`
-	ReactionGroups []Reaction `json:"reactionGroups"`
+	ViewerCanReact bool            `json:"viewerCanReact"`
+	ReactionGroups []ReactionGroup `json:"reactionGroups"`
+}
+
+type ReactionGroup struct {
+	Content ReactionContent `json:"content"`
 }
 
 type Error struct {
diff --git a/head/graphql-golang/test/inputs/graphql/separate-types1.graphql/default/quicktype.go b/head/graphql-golang/test/inputs/graphql/separate-types1.graphql/default/quicktype.go
new file mode 100644
index 0000000..019993c
--- /dev/null
+++ b/head/graphql-golang/test/inputs/graphql/separate-types1.graphql/default/quicktype.go
@@ -0,0 +1,49 @@
+// Code generated from JSON Schema using quicktype. DO NOT EDIT.
+// To parse and unparse this JSON data, add this code to your project and do:
+//
+//    topLevel, err := UnmarshalTopLevel(bytes)
+//    bytes, err = topLevel.Marshal()
+
+package main
+
+import "encoding/json"
+
+func UnmarshalTopLevel(data []byte) (TopLevel, error) {
+	var r TopLevel
+	err := json.Unmarshal(data, &r)
+	return r, err
+}
+
+func (r *TopLevel) Marshal() ([]byte, error) {
+	return json.Marshal(r)
+}
+
+type TopLevel struct {
+	Data   *Data   `json:"data"`
+	Errors []Error `json:"errors,omitempty"`
+}
+
+type Data struct {
+	Grid *Grid `json:"grid"`
+}
+
+type Grid struct {
+	Config *GridConfig `json:"config"`
+	Props  *GridProps  `json:"props"`
+}
+
+type GridConfig struct {
+	Items []*ComponentRef `json:"items"`
+}
+
+type ComponentRef struct {
+	ID *string `json:"id"`
+}
+
+type GridProps struct {
+	Items []*ComponentRef `json:"items"`
+}
+
+type Error struct {
+	Message string `json:"message"`
+}
diff --git a/base/graphql-haskell/test/inputs/graphql/github7.graphql/default/QuickType.hs b/head/graphql-haskell/test/inputs/graphql/github7.graphql/default/QuickType.hs
index 1b52cdb..30fb63c 100644
--- a/base/graphql-haskell/test/inputs/graphql/github7.graphql/default/QuickType.hs
+++ b/head/graphql-haskell/test/inputs/graphql/github7.graphql/default/QuickType.hs
@@ -6,10 +6,14 @@ module QuickType
     , ErrorElement (..)
     , Data (..)
     , User (..)
-    , RepositoryConnection (..)
+    , UserRepositoryConnection (..)
     , RepositoryEdge (..)
     , Repository (..)
-    , Connection (..)
+    , RepositoryRepositoryConnection (..)
+    , IssueConnection (..)
+    , StargazerConnection (..)
+    , UserConnection (..)
+    , StarredRepositoryConnection (..)
     , decodeTopLevel
     ) where
 
@@ -34,12 +38,12 @@ data Data = Data
 
 data User = User
     { loginUser :: Text
-    , starredRepositoriesUser :: Connection
-    , repositoriesUser :: RepositoryConnection
+    , starredRepositoriesUser :: StarredRepositoryConnection
+    , repositoriesUser :: UserRepositoryConnection
     } deriving (Show)
 
-data RepositoryConnection = RepositoryConnection
-    { edgesRepositoryConnection :: Maybe ([(Maybe RepositoryEdge)])
+data UserRepositoryConnection = UserRepositoryConnection
+    { edgesUserRepositoryConnection :: Maybe ([(Maybe RepositoryEdge)])
     } deriving (Show)
 
 data RepositoryEdge = RepositoryEdge
@@ -48,14 +52,30 @@ data RepositoryEdge = RepositoryEdge
 
 data Repository = Repository
     { nameRepository :: Text
-    , stargazersRepository :: Connection
-    , forksRepository :: Connection
-    , watchersRepository :: Connection
-    , issuesRepository :: Connection
+    , stargazersRepository :: StargazerConnection
+    , forksRepository :: RepositoryRepositoryConnection
+    , watchersRepository :: UserConnection
+    , issuesRepository :: IssueConnection
     } deriving (Show)
 
-data Connection = Connection
-    { totalCountConnection :: Int
+data RepositoryRepositoryConnection = RepositoryRepositoryConnection
+    { totalCountRepositoryRepositoryConnection :: Int
+    } deriving (Show)
+
+data IssueConnection = IssueConnection
+    { totalCountIssueConnection :: Int
+    } deriving (Show)
+
+data StargazerConnection = StargazerConnection
+    { totalCountStargazerConnection :: Int
+    } deriving (Show)
+
+data UserConnection = UserConnection
+    { totalCountUserConnection :: Int
+    } deriving (Show)
+
+data StarredRepositoryConnection = StarredRepositoryConnection
+    { totalCountStarredRepositoryConnection :: Int
     } deriving (Show)
 
 decodeTopLevel :: ByteString -> Maybe QuickType
@@ -107,14 +127,14 @@ instance FromJSON User where
         <*> v .: "starredRepositories"
         <*> v .: "repositories"
 
-instance ToJSON RepositoryConnection where
-    toJSON (RepositoryConnection edgesRepositoryConnection) =
+instance ToJSON UserRepositoryConnection where
+    toJSON (UserRepositoryConnection edgesUserRepositoryConnection) =
         object
-        [ "edges" .= edgesRepositoryConnection
+        [ "edges" .= edgesUserRepositoryConnection
         ]
 
-instance FromJSON RepositoryConnection where
-    parseJSON (Object v) = RepositoryConnection
+instance FromJSON UserRepositoryConnection where
+    parseJSON (Object v) = UserRepositoryConnection
         <$> v .: "edges"
 
 instance ToJSON RepositoryEdge where
@@ -145,12 +165,52 @@ instance FromJSON Repository where
         <*> v .: "watchers"
         <*> v .: "issues"
 
-instance ToJSON Connection where
-    toJSON (Connection totalCountConnection) =
+instance ToJSON RepositoryRepositoryConnection where
+    toJSON (RepositoryRepositoryConnection totalCountRepositoryRepositoryConnection) =
+        object
+        [ "totalCount" .= totalCountRepositoryRepositoryConnection
+        ]
+
+instance FromJSON RepositoryRepositoryConnection where
+    parseJSON (Object v) = RepositoryRepositoryConnection
+        <$> v .: "totalCount"
+
+instance ToJSON IssueConnection where
+    toJSON (IssueConnection totalCountIssueConnection) =
+        object
+        [ "totalCount" .= totalCountIssueConnection
+        ]
+
+instance FromJSON IssueConnection where
+    parseJSON (Object v) = IssueConnection
+        <$> v .: "totalCount"
+
+instance ToJSON StargazerConnection where
+    toJSON (StargazerConnection totalCountStargazerConnection) =
+        object
+        [ "totalCount" .= totalCountStargazerConnection
+        ]
+
+instance FromJSON StargazerConnection where
+    parseJSON (Object v) = StargazerConnection
+        <$> v .: "totalCount"
+
+instance ToJSON UserConnection where
+    toJSON (UserConnection totalCountUserConnection) =
+        object
+        [ "totalCount" .= totalCountUserConnection
+        ]
+
+instance FromJSON UserConnection where
+    parseJSON (Object v) = UserConnection
+        <$> v .: "totalCount"
+
+instance ToJSON StarredRepositoryConnection where
+    toJSON (StarredRepositoryConnection totalCountStarredRepositoryConnection) =
         object
-        [ "totalCount" .= totalCountConnection
+        [ "totalCount" .= totalCountStarredRepositoryConnection
         ]
 
-instance FromJSON Connection where
-    parseJSON (Object v) = Connection
+instance FromJSON StarredRepositoryConnection where
+    parseJSON (Object v) = StarredRepositoryConnection
         <$> v .: "totalCount"
diff --git a/base/graphql-haskell/test/inputs/graphql/github9.graphql/default/QuickType.hs b/head/graphql-haskell/test/inputs/graphql/github9.graphql/default/QuickType.hs
index 1b85d9c..3a887f8 100644
--- a/base/graphql-haskell/test/inputs/graphql/github9.graphql/default/QuickType.hs
+++ b/head/graphql-haskell/test/inputs/graphql/github9.graphql/default/QuickType.hs
@@ -7,6 +7,7 @@ module QuickType
     , AddReactionPayload (..)
     , Reaction (..)
     , Reactable (..)
+    , ReactionGroup (..)
     , ErrorElement (..)
     , ReactionContent (..)
     , decodeTopLevel
@@ -48,7 +49,11 @@ data ReactionContent
 
 data Reactable = Reactable
     { viewerCanReactReactable :: Bool
-    , reactionGroupsReactable :: Maybe ([Reaction])
+    , reactionGroupsReactable :: Maybe ([ReactionGroup])
+    } deriving (Show)
+
+data ReactionGroup = ReactionGroup
+    { contentReactionGroup :: ReactionContent
     } deriving (Show)
 
 data ErrorElement = ErrorElement
@@ -134,6 +139,16 @@ instance FromJSON Reactable where
         <$> v .: "viewerCanReact"
         <*> v .: "reactionGroups"
 
+instance ToJSON ReactionGroup where
+    toJSON (ReactionGroup contentReactionGroup) =
+        object
+        [ "content" .= contentReactionGroup
+        ]
+
+instance FromJSON ReactionGroup where
+    parseJSON (Object v) = ReactionGroup
+        <$> v .: "content"
+
 instance ToJSON ErrorElement where
     toJSON (ErrorElement messageErrorElement) =
         object
diff --git a/head/graphql-haskell/test/inputs/graphql/separate-types1.graphql/default/QuickType.hs b/head/graphql-haskell/test/inputs/graphql/separate-types1.graphql/default/QuickType.hs
new file mode 100644
index 0000000..fe85b1a
--- /dev/null
+++ b/head/graphql-haskell/test/inputs/graphql/separate-types1.graphql/default/QuickType.hs
@@ -0,0 +1,126 @@
+{-# LANGUAGE StrictData #-}
+{-# LANGUAGE OverloadedStrings #-}
+
+module QuickType
+    ( QuickType (..)
+    , ErrorElement (..)
+    , Data (..)
+    , Grid (..)
+    , GridConfig (..)
+    , ComponentRef (..)
+    , GridProps (..)
+    , decodeTopLevel
+    ) where
+
+import Data.Aeson
+import Data.Aeson.Types (emptyObject)
+import Data.ByteString.Lazy (ByteString)
+import Data.HashMap.Strict (HashMap)
+import Data.Text (Text)
+
+data QuickType = QuickType
+    { gridQueryDataQuickType :: Maybe Data
+    , errorsQuickType :: Maybe ([ErrorElement])
+    } deriving (Show)
+
+data ErrorElement = ErrorElement
+    { messageErrorElement :: Text
+    } deriving (Show)
+
+data Data = Data
+    { gridData :: Maybe Grid
+    } deriving (Show)
+
+data Grid = Grid
+    { configGrid :: Maybe GridConfig
+    , propsGrid :: Maybe GridProps
+    } deriving (Show)
+
+data GridConfig = GridConfig
+    { itemsGridConfig :: Maybe ([(Maybe ComponentRef)])
+    } deriving (Show)
+
+data ComponentRef = ComponentRef
+    { componentRefIDComponentRef :: Maybe Text
+    } deriving (Show)
+
+data GridProps = GridProps
+    { itemsGridProps :: Maybe ([(Maybe ComponentRef)])
+    } deriving (Show)
+
+decodeTopLevel :: ByteString -> Maybe QuickType
+decodeTopLevel = decode
+
+instance ToJSON QuickType where
+    toJSON (QuickType gridQueryDataQuickType errorsQuickType) =
+        object
+        [ "data" .= gridQueryDataQuickType
+        , "errors" .= errorsQuickType
+        ]
+
+instance FromJSON QuickType where
+    parseJSON (Object v) = QuickType
+        <$> v .: "data"
+        <*> v .:? "errors"
+
+instance ToJSON ErrorElement where
+    toJSON (ErrorElement messageErrorElement) =
+        object
+        [ "message" .= messageErrorElement
+        ]
+
+instance FromJSON ErrorElement where
+    parseJSON (Object v) = ErrorElement
+        <$> v .: "message"
+
+instance ToJSON Data where
+    toJSON (Data gridData) =
+        object
+        [ "grid" .= gridData
+        ]
+
+instance FromJSON Data where
+    parseJSON (Object v) = Data
+        <$> v .: "grid"
+
+instance ToJSON Grid where
+    toJSON (Grid configGrid propsGrid) =
+        object
+        [ "config" .= configGrid
+        , "props" .= propsGrid
+        ]
+
+instance FromJSON Grid where
+    parseJSON (Object v) = Grid
+        <$> v .: "config"
+        <*> v .: "props"
+
+instance ToJSON GridConfig where
+    toJSON (GridConfig itemsGridConfig) =
+        object
+        [ "items" .= itemsGridConfig
+        ]
+
+instance FromJSON GridConfig where
+    parseJSON (Object v) = GridConfig
+        <$> v .: "items"
+
+instance ToJSON ComponentRef where
+    toJSON (ComponentRef componentRefIDComponentRef) =
+        object
+        [ "id" .= componentRefIDComponentRef
+        ]
+
+instance FromJSON ComponentRef where
+    parseJSON (Object v) = ComponentRef
+        <$> v .: "id"
+
+instance ToJSON GridProps where
+    toJSON (GridProps itemsGridProps) =
+        object
+        [ "items" .= itemsGridProps
+        ]
+
+instance FromJSON GridProps where
+    parseJSON (Object v) = GridProps
+        <$> v .: "items"
diff --git a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java b/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java
deleted file mode 100644
index c8922fb..0000000
--- a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.quicktype;
-
-import com.fasterxml.jackson.annotation.*;
-
-public class Connection {
-    private long totalCount;
-
-    @JsonProperty("totalCount")
-    public long getTotalCount() { return totalCount; }
-    @JsonProperty("totalCount")
-    public void setTotalCount(long value) { this.totalCount = value; }
-}
diff --git a/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java
new file mode 100644
index 0000000..326ad00
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class IssueConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
index 24ccd35..4602525 100644
--- a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
@@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.*;
 
 public class Repository {
     private String name;
-    private Connection stargazers;
-    private Connection forks;
-    private Connection watchers;
-    private Connection issues;
+    private StargazerConnection stargazers;
+    private RepositoryRepositoryConnection forks;
+    private UserConnection watchers;
+    private IssueConnection issues;
 
     @JsonProperty("name")
     public String getName() { return name; }
@@ -15,22 +15,22 @@ public class Repository {
     public void setName(String value) { this.name = value; }
 
     @JsonProperty("stargazers")
-    public Connection getStargazers() { return stargazers; }
+    public StargazerConnection getStargazers() { return stargazers; }
     @JsonProperty("stargazers")
-    public void setStargazers(Connection value) { this.stargazers = value; }
+    public void setStargazers(StargazerConnection value) { this.stargazers = value; }
 
     @JsonProperty("forks")
-    public Connection getForks() { return forks; }
+    public RepositoryRepositoryConnection getForks() { return forks; }
     @JsonProperty("forks")
-    public void setForks(Connection value) { this.forks = value; }
+    public void setForks(RepositoryRepositoryConnection value) { this.forks = value; }
 
     @JsonProperty("watchers")
-    public Connection getWatchers() { return watchers; }
+    public UserConnection getWatchers() { return watchers; }
     @JsonProperty("watchers")
-    public void setWatchers(Connection value) { this.watchers = value; }
+    public void setWatchers(UserConnection value) { this.watchers = value; }
 
     @JsonProperty("issues")
-    public Connection getIssues() { return issues; }
+    public IssueConnection getIssues() { return issues; }
     @JsonProperty("issues")
-    public void setIssues(Connection value) { this.issues = value; }
+    public void setIssues(IssueConnection value) { this.issues = value; }
 }
diff --git a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java b/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java
deleted file mode 100644
index 46f2b03..0000000
--- a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.quicktype;
-
-import com.fasterxml.jackson.annotation.*;
-import java.util.List;
-
-public class RepositoryConnection {
-    private List<RepositoryEdge> edges;
-
-    @JsonProperty("edges")
-    public List<RepositoryEdge> getEdges() { return edges; }
-    @JsonProperty("edges")
-    public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
-}
diff --git a/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java
new file mode 100644
index 0000000..9695755
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class RepositoryRepositoryConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java
new file mode 100644
index 0000000..ef40335
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StargazerConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java
new file mode 100644
index 0000000..e53c737
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StarredRepositoryConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
index a3c6b7d..935d6e9 100644
--- a/base/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.*;
 
 public class User {
     private String login;
-    private Connection starredRepositories;
-    private RepositoryConnection repositories;
+    private StarredRepositoryConnection starredRepositories;
+    private UserRepositoryConnection repositories;
 
     @JsonProperty("login")
     public String getLogin() { return login; }
@@ -13,12 +13,12 @@ public class User {
     public void setLogin(String value) { this.login = value; }
 
     @JsonProperty("starredRepositories")
-    public Connection getStarredRepositories() { return starredRepositories; }
+    public StarredRepositoryConnection getStarredRepositories() { return starredRepositories; }
     @JsonProperty("starredRepositories")
-    public void setStarredRepositories(Connection value) { this.starredRepositories = value; }
+    public void setStarredRepositories(StarredRepositoryConnection value) { this.starredRepositories = value; }
 
     @JsonProperty("repositories")
-    public RepositoryConnection getRepositories() { return repositories; }
+    public UserRepositoryConnection getRepositories() { return repositories; }
     @JsonProperty("repositories")
-    public void setRepositories(RepositoryConnection value) { this.repositories = value; }
+    public void setRepositories(UserRepositoryConnection value) { this.repositories = value; }
 }
diff --git a/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java
new file mode 100644
index 0000000..e90cc09
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class UserConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java
new file mode 100644
index 0000000..7c93509
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class UserRepositoryConnection {
+    private List<RepositoryEdge> edges;
+
+    @JsonProperty("edges")
+    public List<RepositoryEdge> getEdges() { return edges; }
+    @JsonProperty("edges")
+    public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
+}
diff --git a/base/graphql-java/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java b/head/graphql-java/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
index 194468b..23b49f2 100644
--- a/base/graphql-java/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
+++ b/head/graphql-java/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
@@ -5,7 +5,7 @@ import java.util.List;
 
 public class Reactable {
     private boolean viewerCanReact;
-    private List<Reaction> reactionGroups;
+    private List<ReactionGroup> reactionGroups;
 
     @JsonProperty("viewerCanReact")
     public boolean getViewerCanReact() { return viewerCanReact; }
@@ -13,7 +13,7 @@ public class Reactable {
     public void setViewerCanReact(boolean value) { this.viewerCanReact = value; }
 
     @JsonProperty("reactionGroups")
-    public List<Reaction> getReactionGroups() { return reactionGroups; }
+    public List<ReactionGroup> getReactionGroups() { return reactionGroups; }
     @JsonProperty("reactionGroups")
-    public void setReactionGroups(List<Reaction> value) { this.reactionGroups = value; }
+    public void setReactionGroups(List<ReactionGroup> value) { this.reactionGroups = value; }
 }
diff --git a/head/graphql-java/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java b/head/graphql-java/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java
new file mode 100644
index 0000000..98037cd
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class ReactionGroup {
+    private ReactionContent content;
+
+    @JsonProperty("content")
+    public ReactionContent getContent() { return content; }
+    @JsonProperty("content")
+    public void setContent(ReactionContent value) { this.content = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java
new file mode 100644
index 0000000..022ce98
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class ComponentRef {
+    private String id;
+
+    @JsonProperty("id")
+    public String getID() { return id; }
+    @JsonProperty("id")
+    public void setID(String value) { this.id = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java
new file mode 100644
index 0000000..a8eb236
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java
@@ -0,0 +1,101 @@
+// To use this code, add the following Maven dependency to your project:
+//
+//
+//     com.fasterxml.jackson.core     : jackson-databind          : 2.9.0
+//     com.fasterxml.jackson.datatype : jackson-datatype-jsr310   : 2.9.0
+//
+// Import this package:
+//
+//     import io.quicktype.Converter;
+//
+// Then you can deserialize a JSON string with
+//
+//     TopLevel data = Converter.fromJsonString(jsonString);
+
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.*;
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.temporal.ChronoField;
+
+public class Converter {
+    // Date-time helpers
+
+    private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_INSTANT)
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetDateTime parseDateTimeString(String str) {
+        return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
+    }
+
+    private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
+            .parseDefaulting(ChronoField.YEAR, 2020)
+            .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
+            .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetTime parseTimeString(String str) {
+        return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
+    }
+    // Serialize/deserialize helpers
+
+    public static TopLevel fromJsonString(String json) throws IOException {
+        return getObjectReader().readValue(json);
+    }
+
+    public static String toJsonString(TopLevel obj) throws JsonProcessingException {
+        return getObjectWriter().writeValueAsString(obj);
+    }
+
+    private static ObjectReader reader;
+    private static ObjectWriter writer;
+
+    private static void instantiateMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.findAndRegisterModules();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        SimpleModule module = new SimpleModule();
+        module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
+            @Override
+            public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseDateTimeString(value);
+            }
+        });
+        mapper.registerModule(module);
+        reader = mapper.readerFor(TopLevel.class);
+        writer = mapper.writerFor(TopLevel.class);
+    }
+
+    private static ObjectReader getObjectReader() {
+        if (reader == null) instantiateMapper();
+        return reader;
+    }
+
+    private static ObjectWriter getObjectWriter() {
+        if (writer == null) instantiateMapper();
+        return writer;
+    }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java
new file mode 100644
index 0000000..6fc128a
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Data {
+    private Grid grid;
+
+    @JsonProperty("grid")
+    public Grid getGrid() { return grid; }
+    @JsonProperty("grid")
+    public void setGrid(Grid value) { this.grid = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java
new file mode 100644
index 0000000..c6199ba
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Error {
+    private String message;
+
+    @JsonProperty("message")
+    public String getMessage() { return message; }
+    @JsonProperty("message")
+    public void setMessage(String value) { this.message = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java
new file mode 100644
index 0000000..52bb86c
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Grid {
+    private GridConfig config;
+    private GridProps props;
+
+    @JsonProperty("config")
+    public GridConfig getConfig() { return config; }
+    @JsonProperty("config")
+    public void setConfig(GridConfig value) { this.config = value; }
+
+    @JsonProperty("props")
+    public GridProps getProps() { return props; }
+    @JsonProperty("props")
+    public void setProps(GridProps value) { this.props = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java
new file mode 100644
index 0000000..1e96b63
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class GridConfig {
+    private List<ComponentRef> items;
+
+    @JsonProperty("items")
+    public List<ComponentRef> getItems() { return items; }
+    @JsonProperty("items")
+    public void setItems(List<ComponentRef> value) { this.items = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java
new file mode 100644
index 0000000..ce32e27
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class GridProps {
+    private List<ComponentRef> items;
+
+    @JsonProperty("items")
+    public List<ComponentRef> getItems() { return items; }
+    @JsonProperty("items")
+    public void setItems(List<ComponentRef> value) { this.items = value; }
+}
diff --git a/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java
new file mode 100644
index 0000000..351a6ff
--- /dev/null
+++ b/head/graphql-java/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java
@@ -0,0 +1,19 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class TopLevel {
+    private Data data;
+    private List<Error> errors;
+
+    @JsonProperty("data")
+    public Data getData() { return data; }
+    @JsonProperty("data")
+    public void setData(Data value) { this.data = value; }
+
+    @JsonProperty("errors")
+    public List<Error> getErrors() { return errors; }
+    @JsonProperty("errors")
+    public void setErrors(List<Error> value) { this.errors = value; }
+}
diff --git a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java b/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java
deleted file mode 100644
index c8922fb..0000000
--- a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.quicktype;
-
-import com.fasterxml.jackson.annotation.*;
-
-public class Connection {
-    private long totalCount;
-
-    @JsonProperty("totalCount")
-    public long getTotalCount() { return totalCount; }
-    @JsonProperty("totalCount")
-    public void setTotalCount(long value) { this.totalCount = value; }
-}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java
new file mode 100644
index 0000000..326ad00
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class IssueConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
index 24ccd35..4602525 100644
--- a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
@@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.*;
 
 public class Repository {
     private String name;
-    private Connection stargazers;
-    private Connection forks;
-    private Connection watchers;
-    private Connection issues;
+    private StargazerConnection stargazers;
+    private RepositoryRepositoryConnection forks;
+    private UserConnection watchers;
+    private IssueConnection issues;
 
     @JsonProperty("name")
     public String getName() { return name; }
@@ -15,22 +15,22 @@ public class Repository {
     public void setName(String value) { this.name = value; }
 
     @JsonProperty("stargazers")
-    public Connection getStargazers() { return stargazers; }
+    public StargazerConnection getStargazers() { return stargazers; }
     @JsonProperty("stargazers")
-    public void setStargazers(Connection value) { this.stargazers = value; }
+    public void setStargazers(StargazerConnection value) { this.stargazers = value; }
 
     @JsonProperty("forks")
-    public Connection getForks() { return forks; }
+    public RepositoryRepositoryConnection getForks() { return forks; }
     @JsonProperty("forks")
-    public void setForks(Connection value) { this.forks = value; }
+    public void setForks(RepositoryRepositoryConnection value) { this.forks = value; }
 
     @JsonProperty("watchers")
-    public Connection getWatchers() { return watchers; }
+    public UserConnection getWatchers() { return watchers; }
     @JsonProperty("watchers")
-    public void setWatchers(Connection value) { this.watchers = value; }
+    public void setWatchers(UserConnection value) { this.watchers = value; }
 
     @JsonProperty("issues")
-    public Connection getIssues() { return issues; }
+    public IssueConnection getIssues() { return issues; }
     @JsonProperty("issues")
-    public void setIssues(Connection value) { this.issues = value; }
+    public void setIssues(IssueConnection value) { this.issues = value; }
 }
diff --git a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java b/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java
deleted file mode 100644
index 46f2b03..0000000
--- a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.quicktype;
-
-import com.fasterxml.jackson.annotation.*;
-import java.util.List;
-
-public class RepositoryConnection {
-    private List<RepositoryEdge> edges;
-
-    @JsonProperty("edges")
-    public List<RepositoryEdge> getEdges() { return edges; }
-    @JsonProperty("edges")
-    public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
-}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java
new file mode 100644
index 0000000..9695755
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class RepositoryRepositoryConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java
new file mode 100644
index 0000000..ef40335
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StargazerConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java
new file mode 100644
index 0000000..e53c737
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StarredRepositoryConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
index a3c6b7d..935d6e9 100644
--- a/base/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.*;
 
 public class User {
     private String login;
-    private Connection starredRepositories;
-    private RepositoryConnection repositories;
+    private StarredRepositoryConnection starredRepositories;
+    private UserRepositoryConnection repositories;
 
     @JsonProperty("login")
     public String getLogin() { return login; }
@@ -13,12 +13,12 @@ public class User {
     public void setLogin(String value) { this.login = value; }
 
     @JsonProperty("starredRepositories")
-    public Connection getStarredRepositories() { return starredRepositories; }
+    public StarredRepositoryConnection getStarredRepositories() { return starredRepositories; }
     @JsonProperty("starredRepositories")
-    public void setStarredRepositories(Connection value) { this.starredRepositories = value; }
+    public void setStarredRepositories(StarredRepositoryConnection value) { this.starredRepositories = value; }
 
     @JsonProperty("repositories")
-    public RepositoryConnection getRepositories() { return repositories; }
+    public UserRepositoryConnection getRepositories() { return repositories; }
     @JsonProperty("repositories")
-    public void setRepositories(RepositoryConnection value) { this.repositories = value; }
+    public void setRepositories(UserRepositoryConnection value) { this.repositories = value; }
 }
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java
new file mode 100644
index 0000000..e90cc09
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class UserConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java
new file mode 100644
index 0000000..7c93509
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class UserRepositoryConnection {
+    private List<RepositoryEdge> edges;
+
+    @JsonProperty("edges")
+    public List<RepositoryEdge> getEdges() { return edges; }
+    @JsonProperty("edges")
+    public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
+}
diff --git a/base/graphql-java-datetime-legacy/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
index 194468b..23b49f2 100644
--- a/base/graphql-java-datetime-legacy/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
@@ -5,7 +5,7 @@ import java.util.List;
 
 public class Reactable {
     private boolean viewerCanReact;
-    private List<Reaction> reactionGroups;
+    private List<ReactionGroup> reactionGroups;
 
     @JsonProperty("viewerCanReact")
     public boolean getViewerCanReact() { return viewerCanReact; }
@@ -13,7 +13,7 @@ public class Reactable {
     public void setViewerCanReact(boolean value) { this.viewerCanReact = value; }
 
     @JsonProperty("reactionGroups")
-    public List<Reaction> getReactionGroups() { return reactionGroups; }
+    public List<ReactionGroup> getReactionGroups() { return reactionGroups; }
     @JsonProperty("reactionGroups")
-    public void setReactionGroups(List<Reaction> value) { this.reactionGroups = value; }
+    public void setReactionGroups(List<ReactionGroup> value) { this.reactionGroups = value; }
 }
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java
new file mode 100644
index 0000000..98037cd
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class ReactionGroup {
+    private ReactionContent content;
+
+    @JsonProperty("content")
+    public ReactionContent getContent() { return content; }
+    @JsonProperty("content")
+    public void setContent(ReactionContent value) { this.content = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java
new file mode 100644
index 0000000..022ce98
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class ComponentRef {
+    private String id;
+
+    @JsonProperty("id")
+    public String getID() { return id; }
+    @JsonProperty("id")
+    public void setID(String value) { this.id = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java
new file mode 100644
index 0000000..7d4811b
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java
@@ -0,0 +1,121 @@
+// To use this code, add the following Maven dependency to your project:
+//
+//
+//     com.fasterxml.jackson.core     : jackson-databind          : 2.9.0
+//
+//
+// Import this package:
+//
+//     import io.quicktype.Converter;
+//
+// Then you can deserialize a JSON string with
+//
+//     TopLevel data = Converter.fromJsonString(jsonString);
+
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.*;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+
+public class Converter {
+    // Date-time helpers
+
+    private static final String[] DATE_TIME_FORMATS = {
+            "yyyy-MM-dd'T'HH:mm:ss.SX",
+            "yyyy-MM-dd'T'HH:mm:ss.S",
+            "yyyy-MM-dd'T'HH:mm:ssX",
+            "yyyy-MM-dd'T'HH:mm:ss",
+            "yyyy-MM-dd HH:mm:ss.SX",
+            "yyyy-MM-dd HH:mm:ss.S",
+            "yyyy-MM-dd HH:mm:ssX",
+            "yyyy-MM-dd HH:mm:ss",
+            "HH:mm:ss.SZ",
+            "HH:mm:ss.S",
+            "HH:mm:ssZ",
+            "HH:mm:ss",
+            "yyyy-MM-dd",
+    };
+
+    public static Date parseAllDateTimeString(String str) {
+        for (String format : DATE_TIME_FORMATS) {
+            try {
+                return new SimpleDateFormat(format).parse(str);
+            } catch (Exception ex) {
+                // Ignored
+            }
+        }
+        return null;
+    }
+
+    public static String serializeDateTime(Date datetime) {
+        return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ").format(datetime);
+    }
+
+    public static String serializeDate(Date datetime) {
+        return new SimpleDateFormat("yyyy-MM-dd").format(datetime);
+    }
+
+    public static String serializeTime(Date datetime) {
+        return new SimpleDateFormat("hh:mm:ssZ").format(datetime);
+    }
+    // Serialize/deserialize helpers
+
+    public static TopLevel fromJsonString(String json) throws IOException {
+        return getObjectReader().readValue(json);
+    }
+
+    public static String toJsonString(TopLevel obj) throws JsonProcessingException {
+        return getObjectWriter().writeValueAsString(obj);
+    }
+
+    private static ObjectReader reader;
+    private static ObjectWriter writer;
+
+    private static void instantiateMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.findAndRegisterModules();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        SimpleModule module = new SimpleModule();
+        module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
+            @Override
+            public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseAllDateTimeString(value);
+            }
+        });
+        module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
+            @Override
+            public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseAllDateTimeString(value);
+            }
+        });
+        module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
+            @Override
+            public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseAllDateTimeString(value);
+            }
+        });
+        mapper.registerModule(module);
+        reader = mapper.readerFor(TopLevel.class);
+        writer = mapper.writerFor(TopLevel.class);
+    }
+
+    private static ObjectReader getObjectReader() {
+        if (reader == null) instantiateMapper();
+        return reader;
+    }
+
+    private static ObjectWriter getObjectWriter() {
+        if (writer == null) instantiateMapper();
+        return writer;
+    }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java
new file mode 100644
index 0000000..6fc128a
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Data {
+    private Grid grid;
+
+    @JsonProperty("grid")
+    public Grid getGrid() { return grid; }
+    @JsonProperty("grid")
+    public void setGrid(Grid value) { this.grid = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java
new file mode 100644
index 0000000..c6199ba
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Error {
+    private String message;
+
+    @JsonProperty("message")
+    public String getMessage() { return message; }
+    @JsonProperty("message")
+    public void setMessage(String value) { this.message = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java
new file mode 100644
index 0000000..52bb86c
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Grid {
+    private GridConfig config;
+    private GridProps props;
+
+    @JsonProperty("config")
+    public GridConfig getConfig() { return config; }
+    @JsonProperty("config")
+    public void setConfig(GridConfig value) { this.config = value; }
+
+    @JsonProperty("props")
+    public GridProps getProps() { return props; }
+    @JsonProperty("props")
+    public void setProps(GridProps value) { this.props = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java
new file mode 100644
index 0000000..1e96b63
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class GridConfig {
+    private List<ComponentRef> items;
+
+    @JsonProperty("items")
+    public List<ComponentRef> getItems() { return items; }
+    @JsonProperty("items")
+    public void setItems(List<ComponentRef> value) { this.items = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java
new file mode 100644
index 0000000..ce32e27
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class GridProps {
+    private List<ComponentRef> items;
+
+    @JsonProperty("items")
+    public List<ComponentRef> getItems() { return items; }
+    @JsonProperty("items")
+    public void setItems(List<ComponentRef> value) { this.items = value; }
+}
diff --git a/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java
new file mode 100644
index 0000000..351a6ff
--- /dev/null
+++ b/head/graphql-java-datetime-legacy/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java
@@ -0,0 +1,19 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class TopLevel {
+    private Data data;
+    private List<Error> errors;
+
+    @JsonProperty("data")
+    public Data getData() { return data; }
+    @JsonProperty("data")
+    public void setData(Data value) { this.data = value; }
+
+    @JsonProperty("errors")
+    public List<Error> getErrors() { return errors; }
+    @JsonProperty("errors")
+    public void setErrors(List<Error> value) { this.errors = value; }
+}
diff --git a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java b/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java
deleted file mode 100644
index c8922fb..0000000
--- a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Connection.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.quicktype;
-
-import com.fasterxml.jackson.annotation.*;
-
-public class Connection {
-    private long totalCount;
-
-    @JsonProperty("totalCount")
-    public long getTotalCount() { return totalCount; }
-    @JsonProperty("totalCount")
-    public void setTotalCount(long value) { this.totalCount = value; }
-}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java
new file mode 100644
index 0000000..326ad00
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/IssueConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class IssueConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
index 24ccd35..4602525 100644
--- a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/Repository.java
@@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.*;
 
 public class Repository {
     private String name;
-    private Connection stargazers;
-    private Connection forks;
-    private Connection watchers;
-    private Connection issues;
+    private StargazerConnection stargazers;
+    private RepositoryRepositoryConnection forks;
+    private UserConnection watchers;
+    private IssueConnection issues;
 
     @JsonProperty("name")
     public String getName() { return name; }
@@ -15,22 +15,22 @@ public class Repository {
     public void setName(String value) { this.name = value; }
 
     @JsonProperty("stargazers")
-    public Connection getStargazers() { return stargazers; }
+    public StargazerConnection getStargazers() { return stargazers; }
     @JsonProperty("stargazers")
-    public void setStargazers(Connection value) { this.stargazers = value; }
+    public void setStargazers(StargazerConnection value) { this.stargazers = value; }
 
     @JsonProperty("forks")
-    public Connection getForks() { return forks; }
+    public RepositoryRepositoryConnection getForks() { return forks; }
     @JsonProperty("forks")
-    public void setForks(Connection value) { this.forks = value; }
+    public void setForks(RepositoryRepositoryConnection value) { this.forks = value; }
 
     @JsonProperty("watchers")
-    public Connection getWatchers() { return watchers; }
+    public UserConnection getWatchers() { return watchers; }
     @JsonProperty("watchers")
-    public void setWatchers(Connection value) { this.watchers = value; }
+    public void setWatchers(UserConnection value) { this.watchers = value; }
 
     @JsonProperty("issues")
-    public Connection getIssues() { return issues; }
+    public IssueConnection getIssues() { return issues; }
     @JsonProperty("issues")
-    public void setIssues(Connection value) { this.issues = value; }
+    public void setIssues(IssueConnection value) { this.issues = value; }
 }
diff --git a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java b/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java
deleted file mode 100644
index 46f2b03..0000000
--- a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryConnection.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.quicktype;
-
-import com.fasterxml.jackson.annotation.*;
-import java.util.List;
-
-public class RepositoryConnection {
-    private List<RepositoryEdge> edges;
-
-    @JsonProperty("edges")
-    public List<RepositoryEdge> getEdges() { return edges; }
-    @JsonProperty("edges")
-    public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
-}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java
new file mode 100644
index 0000000..9695755
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/RepositoryRepositoryConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class RepositoryRepositoryConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java
new file mode 100644
index 0000000..ef40335
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StargazerConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StargazerConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java
new file mode 100644
index 0000000..e53c737
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/StarredRepositoryConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StarredRepositoryConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
index a3c6b7d..935d6e9 100644
--- a/base/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/User.java
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.*;
 
 public class User {
     private String login;
-    private Connection starredRepositories;
-    private RepositoryConnection repositories;
+    private StarredRepositoryConnection starredRepositories;
+    private UserRepositoryConnection repositories;
 
     @JsonProperty("login")
     public String getLogin() { return login; }
@@ -13,12 +13,12 @@ public class User {
     public void setLogin(String value) { this.login = value; }
 
     @JsonProperty("starredRepositories")
-    public Connection getStarredRepositories() { return starredRepositories; }
+    public StarredRepositoryConnection getStarredRepositories() { return starredRepositories; }
     @JsonProperty("starredRepositories")
-    public void setStarredRepositories(Connection value) { this.starredRepositories = value; }
+    public void setStarredRepositories(StarredRepositoryConnection value) { this.starredRepositories = value; }
 
     @JsonProperty("repositories")
-    public RepositoryConnection getRepositories() { return repositories; }
+    public UserRepositoryConnection getRepositories() { return repositories; }
     @JsonProperty("repositories")
-    public void setRepositories(RepositoryConnection value) { this.repositories = value; }
+    public void setRepositories(UserRepositoryConnection value) { this.repositories = value; }
 }
diff --git a/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java
new file mode 100644
index 0000000..e90cc09
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserConnection.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class UserConnection {
+    private long totalCount;
+
+    @JsonProperty("totalCount")
+    public long getTotalCount() { return totalCount; }
+    @JsonProperty("totalCount")
+    public void setTotalCount(long value) { this.totalCount = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java
new file mode 100644
index 0000000..7c93509
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/github7.graphql/default/src/main/java/io/quicktype/UserRepositoryConnection.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class UserRepositoryConnection {
+    private List<RepositoryEdge> edges;
+
+    @JsonProperty("edges")
+    public List<RepositoryEdge> getEdges() { return edges; }
+    @JsonProperty("edges")
+    public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
+}
diff --git a/base/graphql-java-lombok/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java b/head/graphql-java-lombok/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
index 194468b..23b49f2 100644
--- a/base/graphql-java-lombok/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
+++ b/head/graphql-java-lombok/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/Reactable.java
@@ -5,7 +5,7 @@ import java.util.List;
 
 public class Reactable {
     private boolean viewerCanReact;
-    private List<Reaction> reactionGroups;
+    private List<ReactionGroup> reactionGroups;
 
     @JsonProperty("viewerCanReact")
     public boolean getViewerCanReact() { return viewerCanReact; }
@@ -13,7 +13,7 @@ public class Reactable {
     public void setViewerCanReact(boolean value) { this.viewerCanReact = value; }
 
     @JsonProperty("reactionGroups")
-    public List<Reaction> getReactionGroups() { return reactionGroups; }
+    public List<ReactionGroup> getReactionGroups() { return reactionGroups; }
     @JsonProperty("reactionGroups")
-    public void setReactionGroups(List<Reaction> value) { this.reactionGroups = value; }
+    public void setReactionGroups(List<ReactionGroup> value) { this.reactionGroups = value; }
 }
diff --git a/head/graphql-java-lombok/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java b/head/graphql-java-lombok/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java
new file mode 100644
index 0000000..98037cd
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/github9.graphql/default/src/main/java/io/quicktype/ReactionGroup.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class ReactionGroup {
+    private ReactionContent content;
+
+    @JsonProperty("content")
+    public ReactionContent getContent() { return content; }
+    @JsonProperty("content")
+    public void setContent(ReactionContent value) { this.content = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java
new file mode 100644
index 0000000..022ce98
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/ComponentRef.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class ComponentRef {
+    private String id;
+
+    @JsonProperty("id")
+    public String getID() { return id; }
+    @JsonProperty("id")
+    public void setID(String value) { this.id = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java
new file mode 100644
index 0000000..a8eb236
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Converter.java
@@ -0,0 +1,101 @@
+// To use this code, add the following Maven dependency to your project:
+//
+//
+//     com.fasterxml.jackson.core     : jackson-databind          : 2.9.0
+//     com.fasterxml.jackson.datatype : jackson-datatype-jsr310   : 2.9.0
+//
+// Import this package:
+//
+//     import io.quicktype.Converter;
+//
+// Then you can deserialize a JSON string with
+//
+//     TopLevel data = Converter.fromJsonString(jsonString);
+
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.*;
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.temporal.ChronoField;
+
+public class Converter {
+    // Date-time helpers
+
+    private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_INSTANT)
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetDateTime parseDateTimeString(String str) {
+        return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
+    }
+
+    private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
+            .parseDefaulting(ChronoField.YEAR, 2020)
+            .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
+            .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetTime parseTimeString(String str) {
+        return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
+    }
+    // Serialize/deserialize helpers
+
+    public static TopLevel fromJsonString(String json) throws IOException {
+        return getObjectReader().readValue(json);
+    }
+
+    public static String toJsonString(TopLevel obj) throws JsonProcessingException {
+        return getObjectWriter().writeValueAsString(obj);
+    }
+
+    private static ObjectReader reader;
+    private static ObjectWriter writer;
+
+    private static void instantiateMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.findAndRegisterModules();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        SimpleModule module = new SimpleModule();
+        module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
+            @Override
+            public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseDateTimeString(value);
+            }
+        });
+        mapper.registerModule(module);
+        reader = mapper.readerFor(TopLevel.class);
+        writer = mapper.writerFor(TopLevel.class);
+    }
+
+    private static ObjectReader getObjectReader() {
+        if (reader == null) instantiateMapper();
+        return reader;
+    }
+
+    private static ObjectWriter getObjectWriter() {
+        if (writer == null) instantiateMapper();
+        return writer;
+    }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java
new file mode 100644
index 0000000..6fc128a
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Data.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Data {
+    private Grid grid;
+
+    @JsonProperty("grid")
+    public Grid getGrid() { return grid; }
+    @JsonProperty("grid")
+    public void setGrid(Grid value) { this.grid = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java
new file mode 100644
index 0000000..c6199ba
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Error.java
@@ -0,0 +1,12 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Error {
+    private String message;
+
+    @JsonProperty("message")
+    public String getMessage() { return message; }
+    @JsonProperty("message")
+    public void setMessage(String value) { this.message = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java
new file mode 100644
index 0000000..52bb86c
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/Grid.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class Grid {
+    private GridConfig config;
+    private GridProps props;
+
+    @JsonProperty("config")
+    public GridConfig getConfig() { return config; }
+    @JsonProperty("config")
+    public void setConfig(GridConfig value) { this.config = value; }
+
+    @JsonProperty("props")
+    public GridProps getProps() { return props; }
+    @JsonProperty("props")
+    public void setProps(GridProps value) { this.props = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java
new file mode 100644
index 0000000..1e96b63
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridConfig.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class GridConfig {
+    private List<ComponentRef> items;
+
+    @JsonProperty("items")
+    public List<ComponentRef> getItems() { return items; }
+    @JsonProperty("items")
+    public void setItems(List<ComponentRef> value) { this.items = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java
new file mode 100644
index 0000000..ce32e27
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/GridProps.java
@@ -0,0 +1,13 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class GridProps {
+    private List<ComponentRef> items;
+
+    @JsonProperty("items")
+    public List<ComponentRef> getItems() { return items; }
+    @JsonProperty("items")
+    public void setItems(List<ComponentRef> value) { this.items = value; }
+}
diff --git a/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java
new file mode 100644
index 0000000..351a6ff
--- /dev/null
+++ b/head/graphql-java-lombok/test/inputs/graphql/separate-types1.graphql/default/src/main/java/io/quicktype/TopLevel.java
@@ -0,0 +1,19 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.List;
+
+public class TopLevel {
+    private Data data;
+    private List<Error> errors;
+
+    @JsonProperty("data")
+    public Data getData() { return data; }
+    @JsonProperty("data")
+    public void setData(Data value) { this.data = value; }
+
+    @JsonProperty("errors")
+    public List<Error> getErrors() { return errors; }
+    @JsonProperty("errors")
+    public void setErrors(List<Error> value) { this.errors = value; }
+}
diff --git a/base/graphql-javascript/test/inputs/graphql/github7.graphql/default/TopLevel.js b/head/graphql-javascript/test/inputs/graphql/github7.graphql/default/TopLevel.js
index 53f9a76..e6d3b51 100644
--- a/base/graphql-javascript/test/inputs/graphql/github7.graphql/default/TopLevel.js
+++ b/head/graphql-javascript/test/inputs/graphql/github7.graphql/default/TopLevel.js
@@ -180,10 +180,10 @@ const typeMap = {
     ], false),
     "User": o([
         { json: "login", js: "login", typ: "" },
-        { json: "starredRepositories", js: "starredRepositories", typ: r("Connection") },
-        { json: "repositories", js: "repositories", typ: r("RepositoryConnection") },
+        { json: "starredRepositories", js: "starredRepositories", typ: r("StarredRepositoryConnection") },
+        { json: "repositories", js: "repositories", typ: r("UserRepositoryConnection") },
     ], false),
-    "RepositoryConnection": o([
+    "UserRepositoryConnection": o([
         { json: "edges", js: "edges", typ: u(a(u(r("RepositoryEdge"), null)), null) },
     ], false),
     "RepositoryEdge": o([
@@ -191,12 +191,24 @@ const typeMap = {
     ], false),
     "Repository": o([
         { json: "name", js: "name", typ: "" },
-        { json: "stargazers", js: "stargazers", typ: r("Connection") },
-        { json: "forks", js: "forks", typ: r("Connection") },
-        { json: "watchers", js: "watchers", typ: r("Connection") },
-        { json: "issues", js: "issues", typ: r("Connection") },
+        { json: "stargazers", js: "stargazers", typ: r("StargazerConnection") },
+        { json: "forks", js: "forks", typ: r("RepositoryRepositoryConnection") },
+        { json: "watchers", js: "watchers", typ: r("UserConnection") },
+        { json: "issues", js: "issues", typ: r("IssueConnection") },
     ], false),
-    "Connection": o([
+    "RepositoryRepositoryConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "IssueConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "StargazerConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "UserConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "StarredRepositoryConnection": o([
         { json: "totalCount", js: "totalCount", typ: 0 },
     ], false),
     "Error": o([
diff --git a/base/graphql-javascript/test/inputs/graphql/github9.graphql/default/TopLevel.js b/head/graphql-javascript/test/inputs/graphql/github9.graphql/default/TopLevel.js
index 3c7e068..2a63ea2 100644
--- a/base/graphql-javascript/test/inputs/graphql/github9.graphql/default/TopLevel.js
+++ b/head/graphql-javascript/test/inputs/graphql/github9.graphql/default/TopLevel.js
@@ -188,7 +188,10 @@ const typeMap = {
     ], false),
     "Reactable": o([
         { json: "viewerCanReact", js: "viewerCanReact", typ: true },
-        { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("Reaction")), null) },
+        { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("ReactionGroup")), null) },
+    ], false),
+    "ReactionGroup": o([
+        { json: "content", js: "content", typ: r("ReactionContent") },
     ], false),
     "Error": o([
         { json: "message", js: "message", typ: "" },
diff --git a/head/graphql-javascript/test/inputs/graphql/separate-types1.graphql/default/TopLevel.js b/head/graphql-javascript/test/inputs/graphql/separate-types1.graphql/default/TopLevel.js
new file mode 100644
index 0000000..7c0b7a9
--- /dev/null
+++ b/head/graphql-javascript/test/inputs/graphql/separate-types1.graphql/default/TopLevel.js
@@ -0,0 +1,202 @@
+// To parse this data:
+//
+//   const Convert = require("./TopLevel");
+//
+//   const topLevel = Convert.toTopLevel(json);
+//
+// These functions will throw an error if the JSON doesn't
+// match the expected interface, even if the JSON is valid.
+
+// Converts JSON strings to/from your types
+// and asserts the results of JSON.parse at runtime
+function toTopLevel(json) {
+    return cast(JSON.parse(json), r("TopLevel"));
+}
+
+function topLevelToJson(value) {
+    return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
+}
+
+function invalidValue(typ, val, key, parent = '') {
+    const prettyTyp = prettyTypeName(typ);
+    const parentText = parent ? ` on ${parent}` : '';
+    const keyText = key ? ` for key "${key}"` : '';
+    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
+}
+
+function prettyTypeName(typ) {
+    if (Array.isArray(typ)) {
+        if (typ.length === 2 && typ[0] === undefined) {
+            return `an optional ${prettyTypeName(typ[1])}`;
+        } else {
+            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
+        }
+    } else if (typeof typ === "object" && typ.literal !== undefined) {
+        return typ.literal;
+    } else {
+        return typeof typ;
+    }
+}
+
+function jsonToJSProps(typ) {
+    if (typ.jsonToJS === undefined) {
+        const map = {};
+        typ.props.forEach((p) => map[p.json] = { key: p.js, typ: p.typ });
+        typ.jsonToJS = map;
+    }
+    return typ.jsonToJS;
+}
+
+function jsToJSONProps(typ) {
+    if (typ.jsToJSON === undefined) {
+        const map = {};
+        typ.props.forEach((p) => map[p.js] = { key: p.json, typ: p.typ });
+        typ.jsToJSON = map;
+    }
+    return typ.jsToJSON;
+}
+
+function transform(val, typ, getProps, key = '', parent = '') {
+    function transformPrimitive(typ, val) {
+        if (typeof typ === typeof val) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+
+    function transformUnion(typs, val) {
+        // val must validate against one typ in typs
+        const l = typs.length;
+        for (let i = 0; i < l; i++) {
+            const typ = typs[i];
+            try {
+                return transform(val, typ, getProps);
+            } catch (_) {}
+        }
+        return invalidValue(typs, val, key, parent);
+    }
+
+    function transformEnum(cases, val) {
+        if (cases.indexOf(val) !== -1) return val;
+        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
+    }
+
+    function transformArray(typ, val) {
+        // val must be an array with no invalid elements
+        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
+        return val.map(el => transform(el, typ, getProps));
+    }
+
+    function transformDate(val) {
+        if (val === null) {
+            return null;
+        }
+        const d = new Date(val);
+        if (isNaN(d.valueOf())) {
+            return invalidValue(l("Date"), val, key, parent);
+        }
+        return d;
+    }
+
+    function transformObject(props, additional, val) {
+        if (val === null || typeof val !== "object" || Array.isArray(val)) {
+            return invalidValue(l(ref || "object"), val, key, parent);
+        }
+        const result = {};
+        Object.getOwnPropertyNames(props).forEach(key => {
+            const prop = props[key];
+            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
+            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
+        });
+        Object.getOwnPropertyNames(val).forEach(key => {
+            if (!Object.prototype.hasOwnProperty.call(props, key)) {
+                result[key] = transform(val[key], additional, getProps, key, ref);
+            }
+        });
+        return result;
+    }
+
+    if (typ === "any") return val;
+    if (typ === null) {
+        if (val === null) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+    if (typ === false) return invalidValue(typ, val, key, parent);
+    let ref = undefined;
+    while (typeof typ === "object" && typ.ref !== undefined) {
+        ref = typ.ref;
+        typ = typeMap[typ.ref];
+    }
+    if (Array.isArray(typ)) return transformEnum(typ, val);
+    if (typeof typ === "object") {
+        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
+            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
+            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
+            : invalidValue(typ, val, key, parent);
+    }
+    // Numbers can be parsed by Date but shouldn't be.
+    if (typ === Date && typeof val !== "number") return transformDate(val);
+    return transformPrimitive(typ, val);
+}
+
+function cast(val, typ) {
+    return transform(val, typ, jsonToJSProps);
+}
+
+function uncast(val, typ) {
+    return transform(val, typ, jsToJSONProps);
+}
+
+function l(typ) {
+    return { literal: typ };
+}
+
+function a(typ) {
+    return { arrayItems: typ };
+}
+
+function u(...typs) {
+    return { unionMembers: typs };
+}
+
+function o(props, additional) {
+    return { props, additional };
+}
+
+function m(additional) {
+    const props = [];
+    return { props, additional };
+}
+
+function r(name) {
+    return { ref: name };
+}
+
+const typeMap = {
+    "TopLevel": o([
+        { json: "data", js: "data", typ: u(r("Data"), null) },
+        { json: "errors", js: "errors", typ: u(undefined, a(r("Error"))) },
+    ], false),
+    "Data": o([
+        { json: "grid", js: "grid", typ: u(r("Grid"), null) },
+    ], false),
+    "Grid": o([
+        { json: "config", js: "config", typ: u(r("GridConfig"), null) },
+        { json: "props", js: "props", typ: u(r("GridProps"), null) },
+    ], false),
+    "GridConfig": o([
+        { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
+    ], false),
+    "ComponentRef": o([
+        { json: "id", js: "id", typ: u(null, "") },
+    ], false),
+    "GridProps": o([
+        { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
+    ], false),
+    "Error": o([
+        { json: "message", js: "message", typ: "" },
+    ], false),
+};
+
+module.exports = {
+    "topLevelToJson": topLevelToJson,
+    "toTopLevel": toTopLevel,
+};
diff --git a/base/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.h b/head/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.h
index bd1096d..4654933 100644
--- a/base/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.h
+++ b/head/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.h
@@ -8,10 +8,14 @@
 @class QTTopLevel;
 @class QTData;
 @class QTUser;
-@class QTRepositoryConnection;
+@class QTUserRepositoryConnection;
 @class QTRepositoryEdge;
 @class QTRepository;
-@class QTConnection;
+@class QTRepositoryRepositoryConnection;
+@class QTIssueConnection;
+@class QTStargazerConnection;
+@class QTUserConnection;
+@class QTStarredRepositoryConnection;
 @class QTError;
 
 NS_ASSUME_NONNULL_BEGIN
@@ -41,11 +45,11 @@ NSString   *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
 
 @interface QTUser : NSObject
 @property (nonatomic, copy)   NSString *login;
-@property (nonatomic, strong) QTConnection *starredRepositories;
-@property (nonatomic, strong) QTRepositoryConnection *repositories;
+@property (nonatomic, strong) QTStarredRepositoryConnection *starredRepositories;
+@property (nonatomic, strong) QTUserRepositoryConnection *repositories;
 @end
 
-@interface QTRepositoryConnection : NSObject
+@interface QTUserRepositoryConnection : NSObject
 @property (nonatomic, nullable, copy) NSArray<QTRepositoryEdge *> *edges;
 @end
 
@@ -55,13 +59,29 @@ NSString   *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
 
 @interface QTRepository : NSObject
 @property (nonatomic, copy)   NSString *name;
-@property (nonatomic, strong) QTConnection *stargazers;
-@property (nonatomic, strong) QTConnection *forks;
-@property (nonatomic, strong) QTConnection *watchers;
-@property (nonatomic, strong) QTConnection *issues;
+@property (nonatomic, strong) QTStargazerConnection *stargazers;
+@property (nonatomic, strong) QTRepositoryRepositoryConnection *forks;
+@property (nonatomic, strong) QTUserConnection *watchers;
+@property (nonatomic, strong) QTIssueConnection *issues;
 @end
 
-@interface QTConnection : NSObject
+@interface QTRepositoryRepositoryConnection : NSObject
+@property (nonatomic, assign) NSInteger totalCount;
+@end
+
+@interface QTIssueConnection : NSObject
+@property (nonatomic, assign) NSInteger totalCount;
+@end
+
+@interface QTStargazerConnection : NSObject
+@property (nonatomic, assign) NSInteger totalCount;
+@end
+
+@interface QTUserConnection : NSObject
+@property (nonatomic, assign) NSInteger totalCount;
+@end
+
+@interface QTStarredRepositoryConnection : NSObject
 @property (nonatomic, assign) NSInteger totalCount;
 @end
 
diff --git a/base/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.m b/head/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.m
index 852176b..d0103ec 100644
--- a/base/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.m
+++ b/head/graphql-objective-c/test/inputs/graphql/github7.graphql/default/QTTopLevel.m
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
 - (NSDictionary *)JSONDictionary;
 @end
 
-@interface QTRepositoryConnection (JSONConversion)
+@interface QTUserRepositoryConnection (JSONConversion)
 + (instancetype)fromJSONDictionary:(NSDictionary *)dict;
 - (NSDictionary *)JSONDictionary;
 @end
@@ -38,7 +38,27 @@ NS_ASSUME_NONNULL_BEGIN
 - (NSDictionary *)JSONDictionary;
 @end
 
-@interface QTConnection (JSONConversion)
+@interface QTRepositoryRepositoryConnection (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTIssueConnection (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTStargazerConnection (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTUserConnection (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTStarredRepositoryConnection (JSONConversion)
 + (instancetype)fromJSONDictionary:(NSDictionary *)dict;
 - (NSDictionary *)JSONDictionary;
 @end
@@ -233,8 +253,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 {
     if (self = [super init]) {
         [self setValuesForKeysWithDictionary:dict];
-        _starredRepositories = [QTConnection fromJSONDictionary:(id)_starredRepositories];
-        _repositories = [QTRepositoryConnection fromJSONDictionary:(id)_repositories];
+        _starredRepositories = [QTStarredRepositoryConnection fromJSONDictionary:(id)_starredRepositories];
+        _repositories = [QTUserRepositoryConnection fromJSONDictionary:(id)_repositories];
     }
     return self;
 }
@@ -264,7 +284,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 }
 @end
 
-@implementation QTRepositoryConnection
+@implementation QTUserRepositoryConnection
 + (NSDictionary<NSString *, NSString *> *)properties
 {
     static NSDictionary<NSString *, NSString *> *properties;
@@ -275,7 +295,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 
 + (instancetype)fromJSONDictionary:(NSDictionary *)dict
 {
-    return dict ? [[QTRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
+    return dict ? [[QTUserRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
 }
 
 - (instancetype)initWithJSONDictionary:(NSDictionary *)dict
@@ -289,19 +309,19 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 
 - (void)setValue:(nullable id)value forKey:(NSString *)key
 {
-    id resolved = QTRepositoryConnection.properties[key];
+    id resolved = QTUserRepositoryConnection.properties[key];
     if (resolved) [super setValue:value forKey:resolved];
 }
 
 - (void)setNilValueForKey:(NSString *)key
 {
-    id resolved = QTRepositoryConnection.properties[key];
+    id resolved = QTUserRepositoryConnection.properties[key];
     if (resolved) [super setValue:@(0) forKey:resolved];
 }
 
 - (NSDictionary *)JSONDictionary
 {
-    id dict = [[self dictionaryWithValuesForKeys:QTRepositoryConnection.properties.allValues] mutableCopy];
+    id dict = [[self dictionaryWithValuesForKeys:QTUserRepositoryConnection.properties.allValues] mutableCopy];
 
     [dict addEntriesFromDictionary:@{
         @"edges": NSNullify(map(_edges, λ(id x, NSNullify([x JSONDictionary])))),
@@ -380,10 +400,10 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 {
     if (self = [super init]) {
         [self setValuesForKeysWithDictionary:dict];
-        _stargazers = [QTConnection fromJSONDictionary:(id)_stargazers];
-        _forks = [QTConnection fromJSONDictionary:(id)_forks];
-        _watchers = [QTConnection fromJSONDictionary:(id)_watchers];
-        _issues = [QTConnection fromJSONDictionary:(id)_issues];
+        _stargazers = [QTStargazerConnection fromJSONDictionary:(id)_stargazers];
+        _forks = [QTRepositoryRepositoryConnection fromJSONDictionary:(id)_forks];
+        _watchers = [QTUserConnection fromJSONDictionary:(id)_watchers];
+        _issues = [QTIssueConnection fromJSONDictionary:(id)_issues];
     }
     return self;
 }
@@ -415,7 +435,167 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 }
 @end
 
-@implementation QTConnection
+@implementation QTRepositoryRepositoryConnection
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"totalCount": @"totalCount",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTRepositoryRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTRepositoryRepositoryConnection.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTRepositoryRepositoryConnection.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    return [self dictionaryWithValuesForKeys:QTRepositoryRepositoryConnection.properties.allValues];
+}
+@end
+
+@implementation QTIssueConnection
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"totalCount": @"totalCount",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTIssueConnection alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTIssueConnection.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTIssueConnection.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    return [self dictionaryWithValuesForKeys:QTIssueConnection.properties.allValues];
+}
+@end
+
+@implementation QTStargazerConnection
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"totalCount": @"totalCount",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTStargazerConnection alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTStargazerConnection.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTStargazerConnection.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    return [self dictionaryWithValuesForKeys:QTStargazerConnection.properties.allValues];
+}
+@end
+
+@implementation QTUserConnection
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"totalCount": @"totalCount",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTUserConnection alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTUserConnection.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTUserConnection.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    return [self dictionaryWithValuesForKeys:QTUserConnection.properties.allValues];
+}
+@end
+
+@implementation QTStarredRepositoryConnection
 + (NSDictionary<NSString *, NSString *> *)properties
 {
     static NSDictionary<NSString *, NSString *> *properties;
@@ -426,7 +606,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 
 + (instancetype)fromJSONDictionary:(NSDictionary *)dict
 {
-    return dict ? [[QTConnection alloc] initWithJSONDictionary:dict] : nil;
+    return dict ? [[QTStarredRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
 }
 
 - (instancetype)initWithJSONDictionary:(NSDictionary *)dict
@@ -439,19 +619,19 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 
 - (void)setValue:(nullable id)value forKey:(NSString *)key
 {
-    id resolved = QTConnection.properties[key];
+    id resolved = QTStarredRepositoryConnection.properties[key];
     if (resolved) [super setValue:value forKey:resolved];
 }
 
 - (void)setNilValueForKey:(NSString *)key
 {
-    id resolved = QTConnection.properties[key];
+    id resolved = QTStarredRepositoryConnection.properties[key];
     if (resolved) [super setValue:@(0) forKey:resolved];
 }
 
 - (NSDictionary *)JSONDictionary
 {
-    return [self dictionaryWithValuesForKeys:QTConnection.properties.allValues];
+    return [self dictionaryWithValuesForKeys:QTStarredRepositoryConnection.properties.allValues];
 }
 @end
 
diff --git a/base/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.h b/head/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.h
index 608ae2a..26992b8 100644
--- a/base/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.h
+++ b/head/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.h
@@ -11,6 +11,7 @@
 @class QTReaction;
 @class QTReactionContent;
 @class QTReactable;
+@class QTReactionGroup;
 @class QTError;
 
 NS_ASSUME_NONNULL_BEGIN
@@ -63,7 +64,11 @@ NSString   *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
 
 @interface QTReactable : NSObject
 @property (nonatomic, assign)         BOOL isViewerCanReact;
-@property (nonatomic, nullable, copy) NSArray<QTReaction *> *reactionGroups;
+@property (nonatomic, nullable, copy) NSArray<QTReactionGroup *> *reactionGroups;
+@end
+
+@interface QTReactionGroup : NSObject
+@property (nonatomic, assign) QTReactionContent *content;
 @end
 
 @interface QTError : NSObject
diff --git a/base/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.m b/head/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.m
index 7074927..d39fe2a 100644
--- a/base/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.m
+++ b/head/graphql-objective-c/test/inputs/graphql/github9.graphql/default/QTTopLevel.m
@@ -33,6 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
 - (NSDictionary *)JSONDictionary;
 @end
 
+@interface QTReactionGroup (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
 @interface QTError (JSONConversion)
 + (instancetype)fromJSONDictionary:(NSDictionary *)dict;
 - (NSDictionary *)JSONDictionary;
@@ -363,7 +368,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 {
     if (self = [super init]) {
         [self setValuesForKeysWithDictionary:dict];
-        _reactionGroups = map(_reactionGroups, λ(id x, [QTReaction fromJSONDictionary:x]));
+        _reactionGroups = map(_reactionGroups, λ(id x, [QTReactionGroup fromJSONDictionary:x]));
     }
     return self;
 }
@@ -401,6 +406,53 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
 }
 @end
 
+@implementation QTReactionGroup
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"content": @"content",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTReactionGroup alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+        _content = [QTReactionContent withValue:(id)_content];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTReactionGroup.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTReactionGroup.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    id dict = [[self dictionaryWithValuesForKeys:QTReactionGroup.properties.allValues] mutableCopy];
+
+    [dict addEntriesFromDictionary:@{
+        @"content": [_content value],
+    }];
+
+    return dict;
+}
+@end
+
 @implementation QTError
 + (NSDictionary<NSString *, NSString *> *)properties
 {
diff --git a/head/graphql-objective-c/test/inputs/graphql/separate-types1.graphql/default/QTTopLevel.h b/head/graphql-objective-c/test/inputs/graphql/separate-types1.graphql/default/QTTopLevel.h
new file mode 100644
index 0000000..428c83a
--- /dev/null
+++ b/head/graphql-objective-c/test/inputs/graphql/separate-types1.graphql/default/QTTopLevel.h
@@ -0,0 +1,62 @@
+// To parse this JSON:
+//
+//   NSError *error;
+//   QTTopLevel *topLevel = [QTTopLevel fromJSON:json encoding:NSUTF8Encoding error:&error];
+
+#import <Foundation/Foundation.h>
+
+@class QTTopLevel;
+@class QTData;
+@class QTGrid;
+@class QTGridConfig;
+@class QTComponentRef;
+@class QTGridProps;
+@class QTError;
+
+NS_ASSUME_NONNULL_BEGIN
+
+#pragma mark - Top-level marshaling functions
+
+QTTopLevel *_Nullable QTTopLevelFromData(NSData *data, NSError **error);
+QTTopLevel *_Nullable QTTopLevelFromJSON(NSString *json, NSStringEncoding encoding, NSError **error);
+NSData     *_Nullable QTTopLevelToData(QTTopLevel *topLevel, NSError **error);
+NSString   *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding encoding, NSError **error);
+
+#pragma mark - Object interfaces
+
+@interface QTTopLevel : NSObject
+@property (nonatomic, nullable, strong) QTData *data;
+@property (nonatomic, nullable, copy)   NSArray<QTError *> *errors;
+
++ (_Nullable instancetype)fromJSON:(NSString *)json encoding:(NSStringEncoding)encoding error:(NSError *_Nullable *)error;
++ (_Nullable instancetype)fromData:(NSData *)data error:(NSError *_Nullable *)error;
+- (NSString *_Nullable)toJSON:(NSStringEncoding)encoding error:(NSError *_Nullable *)error;
+- (NSData *_Nullable)toData:(NSError *_Nullable *)error;
+@end
+
+@interface QTData : NSObject
+@property (nonatomic, nullable, strong) QTGrid *grid;
+@end
+
+@interface QTGrid : NSObject
+@property (nonatomic, nullable, strong) QTGridConfig *config;
+@property (nonatomic, nullable, strong) QTGridProps *props;
+@end
+
+@interface QTGridConfig : NSObject
+@property (nonatomic, nullable, copy) NSArray<QTComponentRef *> *items;
+@end
+
+@interface QTComponentRef : NSObject
+@property (nonatomic, nullable, copy) NSString *identifier;
+@end
+
+@interface QTGridProps : NSObject
+@property (nonatomic, nullable, copy) NSArray<QTComponentRef *> *items;
+@end
+
+@interface QTError : NSObject
+@property (nonatomic, copy) NSString *message;
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/head/graphql-objective-c/test/inputs/graphql/separate-types1.graphql/default/QTTopLevel.m b/head/graphql-objective-c/test/inputs/graphql/separate-types1.graphql/default/QTTopLevel.m
new file mode 100644
index 0000000..46cb53e
--- /dev/null
+++ b/head/graphql-objective-c/test/inputs/graphql/separate-types1.graphql/default/QTTopLevel.m
@@ -0,0 +1,445 @@
+#import "QTTopLevel.h"
+
+#define λ(decl, expr) (^(decl) { return (expr); })
+
+static id NSNullify(id _Nullable x) {
+    return (x == nil || x == NSNull.null) ? NSNull.null : x;
+}
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface QTTopLevel (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTData (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTGrid (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTGridConfig (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTComponentRef (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTGridProps (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+@interface QTError (JSONConversion)
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
+- (NSDictionary *)JSONDictionary;
+@end
+
+static id map(id collection, id (^f)(id value)) {
+    id result = nil;
+    if ([collection isKindOfClass:NSArray.class]) {
+            result = [NSMutableArray arrayWithCapacity:[collection count]];
+            for (id x in collection) [result addObject:f(x)];
+    } else if ([collection isKindOfClass:NSDictionary.class]) {
+            result = [NSMutableDictionary dictionaryWithCapacity:[collection count]];
+            for (id key in collection) [result setObject:f([collection objectForKey:key]) forKey:key];
+    }
+    return result;
+}
+
+#pragma mark - JSON serialization
+
+QTTopLevel *_Nullable QTTopLevelFromData(NSData *data, NSError **error)
+{
+    @try {
+        id json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:error];
+        return *error ? nil : [QTTopLevel fromJSONDictionary:json];
+    } @catch (NSException *exception) {
+        *error = [NSError errorWithDomain:@"JSONSerialization" code:-1 userInfo:@{ @"exception": exception }];
+        return nil;
+    }
+}
+
+QTTopLevel *_Nullable QTTopLevelFromJSON(NSString *json, NSStringEncoding encoding, NSError **error)
+{
+    return QTTopLevelFromData([json dataUsingEncoding:encoding], error);
+}
+
+NSData *_Nullable QTTopLevelToData(QTTopLevel *topLevel, NSError **error)
+{
+    @try {
+        id json = [topLevel JSONDictionary];
+        NSData *data = [NSJSONSerialization dataWithJSONObject:json options:kNilOptions error:error];
+        return *error ? nil : data;
+    } @catch (NSException *exception) {
+        *error = [NSError errorWithDomain:@"JSONSerialization" code:-1 userInfo:@{ @"exception": exception }];
+        return nil;
+    }
+}
+
+NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding encoding, NSError **error)
+{
+    NSData *data = QTTopLevelToData(topLevel, error);
+    return data ? [[NSString alloc] initWithData:data encoding:encoding] : nil;
+}
+
+@implementation QTTopLevel
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"data": @"data",
+        @"errors": @"errors",
+    };
+}
+
++ (_Nullable instancetype)fromData:(NSData *)data error:(NSError *_Nullable *)error
+{
+    return QTTopLevelFromData(data, error);
+}
+
++ (_Nullable instancetype)fromJSON:(NSString *)json encoding:(NSStringEncoding)encoding error:(NSError *_Nullable *)error
+{
+    return QTTopLevelFromJSON(json, encoding, error);
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTTopLevel alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+        _data = [QTData fromJSONDictionary:(id)_data];
+        _errors = map(_errors, λ(id x, [QTError fromJSONDictionary:x]));
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTTopLevel.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTTopLevel.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    id dict = [[self dictionaryWithValuesForKeys:QTTopLevel.properties.allValues] mutableCopy];
+
+    [dict addEntriesFromDictionary:@{
+        @"data": NSNullify([_data JSONDictionary]),
+        @"errors": NSNullify(map(_errors, λ(id x, [x JSONDictionary]))),
+    }];
+
+    return dict;
+}
+
+- (NSData *_Nullable)toData:(NSError *_Nullable *)error
+{
+    return QTTopLevelToData(self, error);
+}
+
+- (NSString *_Nullable)toJSON:(NSStringEncoding)encoding error:(NSError *_Nullable *)error
+{
+    return QTTopLevelToJSON(self, encoding, error);
+}
+@end
+
+@implementation QTData
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"grid": @"grid",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTData alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+        _grid = [QTGrid fromJSONDictionary:(id)_grid];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTData.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTData.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    id dict = [[self dictionaryWithValuesForKeys:QTData.properties.allValues] mutableCopy];
+
+    [dict addEntriesFromDictionary:@{
+        @"grid": NSNullify([_grid JSONDictionary]),
+    }];
+
+    return dict;
+}
+@end
+
+@implementation QTGrid
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"config": @"config",
+        @"props": @"props",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTGrid alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+        _config = [QTGridConfig fromJSONDictionary:(id)_config];
+        _props = [QTGridProps fromJSONDictionary:(id)_props];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTGrid.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTGrid.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    id dict = [[self dictionaryWithValuesForKeys:QTGrid.properties.allValues] mutableCopy];
+
+    [dict addEntriesFromDictionary:@{
+        @"config": NSNullify([_config JSONDictionary]),
+        @"props": NSNullify([_props JSONDictionary]),
+    }];
+
+    return dict;
+}
+@end
+
+@implementation QTGridConfig
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"items": @"items",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTGridConfig alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+        _items = map(_items, λ(id x, [QTComponentRef fromJSONDictionary:x]));
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTGridConfig.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTGridConfig.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    id dict = [[self dictionaryWithValuesForKeys:QTGridConfig.properties.allValues] mutableCopy];
+
+    [dict addEntriesFromDictionary:@{
+        @"items": NSNullify(map(_items, λ(id x, NSNullify([x JSONDictionary])))),
+    }];
+
+    return dict;
+}
+@end
+
+@implementation QTComponentRef
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"id": @"identifier",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTComponentRef alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTComponentRef.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTComponentRef.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    id dict = [[self dictionaryWithValuesForKeys:QTComponentRef.properties.allValues] mutableCopy];
+
+    for (id jsonName in QTComponentRef.properties) {
+        id propertyName = QTComponentRef.properties[jsonName];
+        if (![jsonName isEqualToString:propertyName]) {
+            dict[jsonName] = dict[propertyName];
+            [dict removeObjectForKey:propertyName];
+        }
+    }
+
+    return dict;
+}
+@end
+
+@implementation QTGridProps
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"items": @"items",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTGridProps alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+        _items = map(_items, λ(id x, [QTComponentRef fromJSONDictionary:x]));
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTGridProps.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTGridProps.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    id dict = [[self dictionaryWithValuesForKeys:QTGridProps.properties.allValues] mutableCopy];
+
+    [dict addEntriesFromDictionary:@{
+        @"items": NSNullify(map(_items, λ(id x, NSNullify([x JSONDictionary])))),
+    }];
+
+    return dict;
+}
+@end
+
+@implementation QTError
++ (NSDictionary<NSString *, NSString *> *)properties
+{
+    static NSDictionary<NSString *, NSString *> *properties;
+    return properties = properties ? properties : @{
+        @"message": @"message",
+    };
+}
+
++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
+{
+    return dict ? [[QTError alloc] initWithJSONDictionary:dict] : nil;
+}
+
+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
+{
+    if (self = [super init]) {
+        [self setValuesForKeysWithDictionary:dict];
+    }
+    return self;
+}
+
+- (void)setValue:(nullable id)value forKey:(NSString *)key
+{
+    id resolved = QTError.properties[key];
+    if (resolved) [super setValue:value forKey:resolved];
+}
+
+- (void)setNilValueForKey:(NSString *)key
+{
+    id resolved = QTError.properties[key];
+    if (resolved) [super setValue:@(0) forKey:resolved];
+}
+
+- (NSDictionary *)JSONDictionary
+{
+    return [self dictionaryWithValuesForKeys:QTError.properties.allValues];
+}
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/base/graphql-php/test/inputs/graphql/github7.graphql/default/TopLevel.php b/head/graphql-php/test/inputs/graphql/github7.graphql/default/TopLevel.php
index 7c11ccb..437ca7b 100644
--- a/base/graphql-php/test/inputs/graphql/github7.graphql/default/TopLevel.php
+++ b/head/graphql-php/test/inputs/graphql/github7.graphql/default/TopLevel.php
@@ -289,15 +289,15 @@ class Data {
 
 class User {
     private string $login; // json:login Required
-    private Connection $starredRepositories; // json:starredRepositories Required
-    private RepositoryConnection $repositories; // json:repositories Required
+    private StarredRepositoryConnection $starredRepositories; // json:starredRepositories Required
+    private UserRepositoryConnection $repositories; // json:repositories Required
 
     /**
      * @param string $login
-     * @param Connection $starredRepositories
-     * @param RepositoryConnection $repositories
+     * @param StarredRepositoryConnection $starredRepositories
+     * @param UserRepositoryConnection $repositories
      */
-    public function __construct(string $login, Connection $starredRepositories, RepositoryConnection $repositories) {
+    public function __construct(string $login, StarredRepositoryConnection $starredRepositories, UserRepositoryConnection $repositories) {
         $this->login = $login;
         $this->starredRepositories = $starredRepositories;
         $this->repositories = $repositories;
@@ -353,10 +353,10 @@ class User {
     /**
      * @param stdClass $value
      * @throws Exception
-     * @return Connection
+     * @return StarredRepositoryConnection
      */
-    public static function fromStarredRepositories(stdClass $value): Connection {
-        return Connection::from($value); /*class*/
+    public static function fromStarredRepositories(stdClass $value): StarredRepositoryConnection {
+        return StarredRepositoryConnection::from($value); /*class*/
     }
 
     /**
@@ -371,20 +371,20 @@ class User {
     }
 
     /**
-     * @param Connection
+     * @param StarredRepositoryConnection
      * @return bool
      * @throws Exception
      */
-    public static function validateStarredRepositories(Connection $value): bool {
+    public static function validateStarredRepositories(StarredRepositoryConnection $value): bool {
         $value->validate();
         return true;
     }
 
     /**
      * @throws Exception
-     * @return Connection
+     * @return StarredRepositoryConnection
      */
-    public function getStarredRepositories(): Connection {
+    public function getStarredRepositories(): StarredRepositoryConnection {
         if (User::validateStarredRepositories($this->starredRepositories))  {
             return $this->starredRepositories;
         }
@@ -392,19 +392,19 @@ class User {
     }
 
     /**
-     * @return Connection
+     * @return StarredRepositoryConnection
      */
-    public static function sampleStarredRepositories(): Connection {
-        return Connection::sample(); /*32:starredRepositories*/
+    public static function sampleStarredRepositories(): StarredRepositoryConnection {
+        return StarredRepositoryConnection::sample(); /*32:starredRepositories*/
     }
 
     /**
      * @param stdClass $value
      * @throws Exception
-     * @return RepositoryConnection
+     * @return UserRepositoryConnection
      */
-    public static function fromRepositories(stdClass $value): RepositoryConnection {
-        return RepositoryConnection::from($value); /*class*/
+    public static function fromRepositories(stdClass $value): UserRepositoryConnection {
+        return UserRepositoryConnection::from($value); /*class*/
     }
 
     /**
@@ -419,20 +419,20 @@ class User {
     }
 
     /**
-     * @param RepositoryConnection
+     * @param UserRepositoryConnection
      * @return bool
      * @throws Exception
      */
-    public static function validateRepositories(RepositoryConnection $value): bool {
+    public static function validateRepositories(UserRepositoryConnection $value): bool {
         $value->validate();
         return true;
     }
 
     /**
      * @throws Exception
-     * @return RepositoryConnection
+     * @return UserRepositoryConnection
      */
-    public function getRepositories(): RepositoryConnection {
+    public function getRepositories(): UserRepositoryConnection {
         if (User::validateRepositories($this->repositories))  {
             return $this->repositories;
         }
@@ -440,10 +440,10 @@ class User {
     }
 
     /**
-     * @return RepositoryConnection
+     * @return UserRepositoryConnection
      */
-    public static function sampleRepositories(): RepositoryConnection {
-        return RepositoryConnection::sample(); /*33:repositories*/
+    public static function sampleRepositories(): UserRepositoryConnection {
+        return UserRepositoryConnection::sample(); /*33:repositories*/
     }
 
     /**
@@ -493,9 +493,9 @@ class User {
     }
 }
 
-// This is an autogenerated file:RepositoryConnection
+// This is an autogenerated file:UserRepositoryConnection
 
-class RepositoryConnection {
+class UserRepositoryConnection {
     private ?array $edges; // json:edges Optional
 
     /**
@@ -529,7 +529,7 @@ class RepositoryConnection {
      * @return ?array
      */
     public function toEdges(): ?array {
-        if (RepositoryConnection::validateEdges($this->edges))  {
+        if (UserRepositoryConnection::validateEdges($this->edges))  {
             if (!is_null($this->edges)) {
                 return array_map(function ($value) {
                     if (!is_null($value)) {
@@ -542,7 +542,7 @@ class RepositoryConnection {
                 return  null;
             }
         }
-        throw new Exception('never get to this RepositoryConnection::edges');
+        throw new Exception('never get to this UserRepositoryConnection::edges');
     }
 
     /**
@@ -553,7 +553,7 @@ class RepositoryConnection {
     public static function validateEdges(?array $value): bool {
         if (!is_null($value)) {
             if (!is_array($value)) {
-                throw new Exception("Attribute Error:RepositoryConnection::edges");
+                throw new Exception("Attribute Error:UserRepositoryConnection::edges");
             }
             array_walk($value, function($value_v) {
                 if (!is_null($value_v)) {
@@ -569,10 +569,10 @@ class RepositoryConnection {
      * @return ?array
      */
     public function getEdges(): ?array {
-        if (RepositoryConnection::validateEdges($this->edges))  {
+        if (UserRepositoryConnection::validateEdges($this->edges))  {
             return $this->edges;
         }
-        throw new Exception('never get to getEdges RepositoryConnection::edges');
+        throw new Exception('never get to getEdges UserRepositoryConnection::edges');
     }
 
     /**
@@ -589,7 +589,7 @@ class RepositoryConnection {
      * @return bool
      */
     public function validate(): bool {
-        return RepositoryConnection::validateEdges($this->edges);
+        return UserRepositoryConnection::validateEdges($this->edges);
     }
 
     /**
@@ -604,21 +604,21 @@ class RepositoryConnection {
 
     /**
      * @param stdClass $obj
-     * @return RepositoryConnection
+     * @return UserRepositoryConnection
      * @throws Exception
      */
-    public static function from(stdClass $obj): RepositoryConnection {
-        return new RepositoryConnection(
-         RepositoryConnection::fromEdges($obj->{'edges'})
+    public static function from(stdClass $obj): UserRepositoryConnection {
+        return new UserRepositoryConnection(
+         UserRepositoryConnection::fromEdges($obj->{'edges'})
         );
     }
 
     /**
-     * @return RepositoryConnection
+     * @return UserRepositoryConnection
      */
-    public static function sample(): RepositoryConnection {
-        return new RepositoryConnection(
-         RepositoryConnection::sampleEdges()
+    public static function sample(): UserRepositoryConnection {
+        return new UserRepositoryConnection(
+         UserRepositoryConnection::sampleEdges()
         );
     }
 }
@@ -736,19 +736,19 @@ class RepositoryEdge {
 
 class Repository {
     private string $name; // json:name Required
-    private Connection $stargazers; // json:stargazers Required
-    private Connection $forks; // json:forks Required
-    private Connection $watchers; // json:watchers Required
-    private Connection $issues; // json:issues Required
+    private StargazerConnection $stargazers; // json:stargazers Required
+    private RepositoryRepositoryConnection $forks; // json:forks Required
+    private UserConnection $watchers; // json:watchers Required
+    private IssueConnection $issues; // json:issues Required
 
     /**
      * @param string $name
-     * @param Connection $stargazers
-     * @param Connection $forks
-     * @param Connection $watchers
-     * @param Connection $issues
+     * @param StargazerConnection $stargazers
+     * @param RepositoryRepositoryConnection $forks
+     * @param UserConnection $watchers
+     * @param IssueConnection $issues
      */
-    public function __construct(string $name, Connection $stargazers, Connection $forks, Connection $watchers, Connection $issues) {
+    public function __construct(string $name, StargazerConnection $stargazers, RepositoryRepositoryConnection $forks, UserConnection $watchers, IssueConnection $issues) {
         $this->name = $name;
         $this->stargazers = $stargazers;
         $this->forks = $forks;
@@ -806,10 +806,10 @@ class Repository {
     /**
      * @param stdClass $value
      * @throws Exception
-     * @return Connection
+     * @return StargazerConnection
      */
-    public static function fromStargazers(stdClass $value): Connection {
-        return Connection::from($value); /*class*/
+    public static function fromStargazers(stdClass $value): StargazerConnection {
+        return StargazerConnection::from($value); /*class*/
     }
 
     /**
@@ -824,20 +824,20 @@ class Repository {
     }
 
     /**
-     * @param Connection
+     * @param StargazerConnection
      * @return bool
      * @throws Exception
      */
-    public static function validateStargazers(Connection $value): bool {
+    public static function validateStargazers(StargazerConnection $value): bool {
         $value->validate();
         return true;
     }
 
     /**
      * @throws Exception
-     * @return Connection
+     * @return StargazerConnection
      */
-    public function getStargazers(): Connection {
+    public function getStargazers(): StargazerConnection {
         if (Repository::validateStargazers($this->stargazers))  {
             return $this->stargazers;
         }
@@ -845,19 +845,19 @@ class Repository {
     }
 
     /**
-     * @return Connection
+     * @return StargazerConnection
      */
-    public static function sampleStargazers(): Connection {
-        return Connection::sample(); /*32:stargazers*/
+    public static function sampleStargazers(): StargazerConnection {
+        return StargazerConnection::sample(); /*32:stargazers*/
     }
 
     /**
      * @param stdClass $value
      * @throws Exception
-     * @return Connection
+     * @return RepositoryRepositoryConnection
      */
-    public static function fromForks(stdClass $value): Connection {
-        return Connection::from($value); /*class*/
+    public static function fromForks(stdClass $value): RepositoryRepositoryConnection {
+        return RepositoryRepositoryConnection::from($value); /*class*/
     }
 
     /**
@@ -872,20 +872,20 @@ class Repository {
     }
 
     /**
-     * @param Connection
+     * @param RepositoryRepositoryConnection
      * @return bool
      * @throws Exception
      */
-    public static function validateForks(Connection $value): bool {
+    public static function validateForks(RepositoryRepositoryConnection $value): bool {
         $value->validate();
         return true;
     }
 
     /**
      * @throws Exception
-     * @return Connection
+     * @return RepositoryRepositoryConnection
      */
-    public function getForks(): Connection {
+    public function getForks(): RepositoryRepositoryConnection {
         if (Repository::validateForks($this->forks))  {
             return $this->forks;
         }
@@ -893,19 +893,19 @@ class Repository {
     }
 
     /**
-     * @return Connection
+     * @return RepositoryRepositoryConnection
      */
-    public static function sampleForks(): Connection {
-        return Connection::sample(); /*33:forks*/
+    public static function sampleForks(): RepositoryRepositoryConnection {
+        return RepositoryRepositoryConnection::sample(); /*33:forks*/
     }
 
     /**
      * @param stdClass $value
      * @throws Exception
-     * @return Connection
+     * @return UserConnection
      */
-    public static function fromWatchers(stdClass $value): Connection {
-        return Connection::from($value); /*class*/
+    public static function fromWatchers(stdClass $value): UserConnection {
+        return UserConnection::from($value); /*class*/
     }
 
     /**
@@ -920,20 +920,20 @@ class Repository {
     }
 
     /**
-     * @param Connection
+     * @param UserConnection
      * @return bool
      * @throws Exception
      */
-    public static function validateWatchers(Connection $value): bool {
+    public static function validateWatchers(UserConnection $value): bool {
         $value->validate();
         return true;
     }
 
     /**
      * @throws Exception
-     * @return Connection
+     * @return UserConnection
      */
-    public function getWatchers(): Connection {
+    public function getWatchers(): UserConnection {
         if (Repository::validateWatchers($this->watchers))  {
             return $this->watchers;
         }
@@ -941,19 +941,19 @@ class Repository {
     }
 
     /**
-     * @return Connection
+     * @return UserConnection
      */
-    public static function sampleWatchers(): Connection {
-        return Connection::sample(); /*34:watchers*/
+    public static function sampleWatchers(): UserConnection {
+        return UserConnection::sample(); /*34:watchers*/
     }
 
     /**
      * @param stdClass $value
      * @throws Exception
-     * @return Connection
+     * @return IssueConnection
      */
-    public static function fromIssues(stdClass $value): Connection {
-        return Connection::from($value); /*class*/
+    public static function fromIssues(stdClass $value): IssueConnection {
+        return IssueConnection::from($value); /*class*/
     }
 
     /**
@@ -968,20 +968,20 @@ class Repository {
     }
 
     /**
-     * @param Connection
+     * @param IssueConnection
      * @return bool
      * @throws Exception
      */
-    public static function validateIssues(Connection $value): bool {
+    public static function validateIssues(IssueConnection $value): bool {
         $value->validate();
         return true;
     }
 
     /**
      * @throws Exception
-     * @return Connection
+     * @return IssueConnection
      */
-    public function getIssues(): Connection {
+    public function getIssues(): IssueConnection {
         if (Repository::validateIssues($this->issues))  {
             return $this->issues;
         }
@@ -989,10 +989,10 @@ class Repository {
     }
 
     /**
-     * @return Connection
+     * @return IssueConnection
      */
-    public static function sampleIssues(): Connection {
-        return Connection::sample(); /*35:issues*/
+    public static function sampleIssues(): IssueConnection {
+        return IssueConnection::sample(); /*35:issues*/
     }
 
     /**
@@ -1050,9 +1050,9 @@ class Repository {
     }
 }
 
-// This is an autogenerated file:Connection
+// This is an autogenerated file:RepositoryRepositoryConnection
 
-class Connection {
+class RepositoryRepositoryConnection {
     private int $totalCount; // json:totalCount Required
 
     /**
@@ -1076,10 +1076,10 @@ class Connection {
      * @return int
      */
     public function toTotalCount(): int {
-        if (Connection::validateTotalCount($this->totalCount))  {
+        if (RepositoryRepositoryConnection::validateTotalCount($this->totalCount))  {
             return $this->totalCount; /*int*/
         }
-        throw new Exception('never get to this Connection::totalCount');
+        throw new Exception('never get to this RepositoryRepositoryConnection::totalCount');
     }
 
     /**
@@ -1096,10 +1096,10 @@ class Connection {
      * @return int
      */
     public function getTotalCount(): int {
-        if (Connection::validateTotalCount($this->totalCount))  {
+        if (RepositoryRepositoryConnection::validateTotalCount($this->totalCount))  {
             return $this->totalCount;
         }
-        throw new Exception('never get to getTotalCount Connection::totalCount');
+        throw new Exception('never get to getTotalCount RepositoryRepositoryConnection::totalCount');
     }
 
     /**
@@ -1114,7 +1114,7 @@ class Connection {
      * @return bool
      */
     public function validate(): bool {
-        return Connection::validateTotalCount($this->totalCount);
+        return RepositoryRepositoryConnection::validateTotalCount($this->totalCount);
     }
 
     /**
@@ -1129,21 +1129,413 @@ class Connection {
 
     /**
      * @param stdClass $obj
-     * @return Connection
+     * @return RepositoryRepositoryConnection
      * @throws Exception
      */
-    public static function from(stdClass $obj): Connection {
-        return new Connection(
-         Connection::fromTotalCount($obj->{'totalCount'})
+    public static function from(stdClass $obj): RepositoryRepositoryConnection {
+        return new RepositoryRepositoryConnection(
+         RepositoryRepositoryConnection::fromTotalCount($obj->{'totalCount'})
         );
     }
 
     /**
-     * @return Connection
+     * @return RepositoryRepositoryConnection
      */
-    public static function sample(): Connection {
-        return new Connection(
-         Connection::sampleTotalCount()
+    public static function sample(): RepositoryRepositoryConnection {
+        return new RepositoryRepositoryConnection(
+         RepositoryRepositoryConnection::sampleTotalCount()
+        );
+    }
+}
+
+// This is an autogenerated file:IssueConnection
+
+class IssueConnection {
+    private int $totalCount; // json:totalCount Required
+
+    /**
+     * @param int $totalCount
+     */
+    public function __construct(int $totalCount) {
+        $this->totalCount = $totalCount;
+    }
+
+    /**
+     * @param int $value
+     * @throws Exception
+     * @return int
+     */
+    public static function fromTotalCount(int $value): int {
+        return $value; /*int*/
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function toTotalCount(): int {
+        if (IssueConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount; /*int*/
+        }
+        throw new Exception('never get to this IssueConnection::totalCount');
+    }
+
+    /**
+     * @param int
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateTotalCount(int $value): bool {
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function getTotalCount(): int {
+        if (IssueConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount;
+        }
+        throw new Exception('never get to getTotalCount IssueConnection::totalCount');
+    }
+
+    /**
+     * @return int
+     */
+    public static function sampleTotalCount(): int {
+        return 31; /*31:totalCount*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return IssueConnection::validateTotalCount($this->totalCount);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'totalCount'} = $this->toTotalCount();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return IssueConnection
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): IssueConnection {
+        return new IssueConnection(
+         IssueConnection::fromTotalCount($obj->{'totalCount'})
+        );
+    }
+
+    /**
+     * @return IssueConnection
+     */
+    public static function sample(): IssueConnection {
+        return new IssueConnection(
+         IssueConnection::sampleTotalCount()
+        );
+    }
+}
+
+// This is an autogenerated file:StargazerConnection
+
+class StargazerConnection {
+    private int $totalCount; // json:totalCount Required
+
+    /**
+     * @param int $totalCount
+     */
+    public function __construct(int $totalCount) {
+        $this->totalCount = $totalCount;
+    }
+
+    /**
+     * @param int $value
+     * @throws Exception
+     * @return int
+     */
+    public static function fromTotalCount(int $value): int {
+        return $value; /*int*/
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function toTotalCount(): int {
+        if (StargazerConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount; /*int*/
+        }
+        throw new Exception('never get to this StargazerConnection::totalCount');
+    }
+
+    /**
+     * @param int
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateTotalCount(int $value): bool {
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function getTotalCount(): int {
+        if (StargazerConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount;
+        }
+        throw new Exception('never get to getTotalCount StargazerConnection::totalCount');
+    }
+
+    /**
+     * @return int
+     */
+    public static function sampleTotalCount(): int {
+        return 31; /*31:totalCount*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return StargazerConnection::validateTotalCount($this->totalCount);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'totalCount'} = $this->toTotalCount();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return StargazerConnection
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): StargazerConnection {
+        return new StargazerConnection(
+         StargazerConnection::fromTotalCount($obj->{'totalCount'})
+        );
+    }
+
+    /**
+     * @return StargazerConnection
+     */
+    public static function sample(): StargazerConnection {
+        return new StargazerConnection(
+         StargazerConnection::sampleTotalCount()
+        );
+    }
+}
+
+// This is an autogenerated file:UserConnection
+
+class UserConnection {
+    private int $totalCount; // json:totalCount Required
+
+    /**
+     * @param int $totalCount
+     */
+    public function __construct(int $totalCount) {
+        $this->totalCount = $totalCount;
+    }
+
+    /**
+     * @param int $value
+     * @throws Exception
+     * @return int
+     */
+    public static function fromTotalCount(int $value): int {
+        return $value; /*int*/
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function toTotalCount(): int {
+        if (UserConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount; /*int*/
+        }
+        throw new Exception('never get to this UserConnection::totalCount');
+    }
+
+    /**
+     * @param int
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateTotalCount(int $value): bool {
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function getTotalCount(): int {
+        if (UserConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount;
+        }
+        throw new Exception('never get to getTotalCount UserConnection::totalCount');
+    }
+
+    /**
+     * @return int
+     */
+    public static function sampleTotalCount(): int {
+        return 31; /*31:totalCount*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return UserConnection::validateTotalCount($this->totalCount);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'totalCount'} = $this->toTotalCount();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return UserConnection
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): UserConnection {
+        return new UserConnection(
+         UserConnection::fromTotalCount($obj->{'totalCount'})
+        );
+    }
+
+    /**
+     * @return UserConnection
+     */
+    public static function sample(): UserConnection {
+        return new UserConnection(
+         UserConnection::sampleTotalCount()
+        );
+    }
+}
+
+// This is an autogenerated file:StarredRepositoryConnection
+
+class StarredRepositoryConnection {
+    private int $totalCount; // json:totalCount Required
+
+    /**
+     * @param int $totalCount
+     */
+    public function __construct(int $totalCount) {
+        $this->totalCount = $totalCount;
+    }
+
+    /**
+     * @param int $value
+     * @throws Exception
+     * @return int
+     */
+    public static function fromTotalCount(int $value): int {
+        return $value; /*int*/
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function toTotalCount(): int {
+        if (StarredRepositoryConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount; /*int*/
+        }
+        throw new Exception('never get to this StarredRepositoryConnection::totalCount');
+    }
+
+    /**
+     * @param int
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateTotalCount(int $value): bool {
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return int
+     */
+    public function getTotalCount(): int {
+        if (StarredRepositoryConnection::validateTotalCount($this->totalCount))  {
+            return $this->totalCount;
+        }
+        throw new Exception('never get to getTotalCount StarredRepositoryConnection::totalCount');
+    }
+
+    /**
+     * @return int
+     */
+    public static function sampleTotalCount(): int {
+        return 31; /*31:totalCount*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return StarredRepositoryConnection::validateTotalCount($this->totalCount);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'totalCount'} = $this->toTotalCount();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return StarredRepositoryConnection
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): StarredRepositoryConnection {
+        return new StarredRepositoryConnection(
+         StarredRepositoryConnection::fromTotalCount($obj->{'totalCount'})
+        );
+    }
+
+    /**
+     * @return StarredRepositoryConnection
+     */
+    public static function sample(): StarredRepositoryConnection {
+        return new StarredRepositoryConnection(
+         StarredRepositoryConnection::sampleTotalCount()
         );
     }
 }
diff --git a/base/graphql-php/test/inputs/graphql/github9.graphql/default/TopLevel.php b/head/graphql-php/test/inputs/graphql/github9.graphql/default/TopLevel.php
index ab59c1c..26cee2e 100644
--- a/base/graphql-php/test/inputs/graphql/github9.graphql/default/TopLevel.php
+++ b/head/graphql-php/test/inputs/graphql/github9.graphql/default/TopLevel.php
@@ -747,7 +747,7 @@ class Reactable {
     public static function fromReactionGroups(?array $value): ?array {
         if (!is_null($value)) {
             return  array_map(function ($value) {
-                return Reaction::from($value); /*class*/
+                return ReactionGroup::from($value); /*class*/
             }, $value);
         } else {
             return  null;
@@ -804,7 +804,7 @@ class Reactable {
      */
     public static function sampleReactionGroups(): ?array {
         return  array(
-            Reaction::sample() /*32:*/
+            ReactionGroup::sample() /*32:*/
         ); /* 32:reactionGroups*/
     }
 
@@ -851,6 +851,105 @@ class Reactable {
     }
 }
 
+// This is an autogenerated file:ReactionGroup
+
+class ReactionGroup {
+    private ReactionContent $content; // json:content Required
+
+    /**
+     * @param ReactionContent $content
+     */
+    public function __construct(ReactionContent $content) {
+        $this->content = $content;
+    }
+
+    /**
+     * @param string $value
+     * @throws Exception
+     * @return ReactionContent
+     */
+    public static function fromContent(string $value): ReactionContent {
+        return ReactionContent::from($value); /*enum*/
+    }
+
+    /**
+     * @throws Exception
+     * @return string
+     */
+    public function toContent(): string {
+        if (ReactionGroup::validateContent($this->content))  {
+            return ReactionContent::to($this->content); /*enum*/
+        }
+        throw new Exception('never get to this ReactionGroup::content');
+    }
+
+    /**
+     * @param ReactionContent
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateContent(ReactionContent $value): bool {
+        ReactionContent::to($value);
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ReactionContent
+     */
+    public function getContent(): ReactionContent {
+        if (ReactionGroup::validateContent($this->content))  {
+            return $this->content;
+        }
+        throw new Exception('never get to getContent ReactionGroup::content');
+    }
+
+    /**
+     * @return ReactionContent
+     */
+    public static function sampleContent(): ReactionContent {
+        return ReactionContent::sample(); /*enum*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return ReactionGroup::validateContent($this->content);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'content'} = $this->toContent();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return ReactionGroup
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): ReactionGroup {
+        return new ReactionGroup(
+         ReactionGroup::fromContent($obj->{'content'})
+        );
+    }
+
+    /**
+     * @return ReactionGroup
+     */
+    public static function sample(): ReactionGroup {
+        return new ReactionGroup(
+         ReactionGroup::sampleContent()
+        );
+    }
+}
+
 // This is an autogenerated file:Error
 
 class Error {
diff --git a/head/graphql-php/test/inputs/graphql/separate-types1.graphql/default/TopLevel.php b/head/graphql-php/test/inputs/graphql/separate-types1.graphql/default/TopLevel.php
new file mode 100644
index 0000000..6a4747b
--- /dev/null
+++ b/head/graphql-php/test/inputs/graphql/separate-types1.graphql/default/TopLevel.php
@@ -0,0 +1,936 @@
+<?php
+declare(strict_types=1);
+
+// This is an autogenerated file:TopLevel
+
+class TopLevel {
+    private ?Data $data; // json:data Optional
+    private ?array $errors; // json:errors Optional
+
+    /**
+     * @param Data|null $data
+     * @param array|null $errors
+     */
+    public function __construct(?Data $data, ?array $errors) {
+        $this->data = $data;
+        $this->errors = $errors;
+    }
+
+    /**
+     * @param ?stdClass $value
+     * @throws Exception
+     * @return ?Data
+     */
+    public static function fromData(?stdClass $value): ?Data {
+        if (!is_null($value)) {
+            return Data::from($value); /*class*/
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?stdClass
+     */
+    public function toData(): ?stdClass {
+        if (TopLevel::validateData($this->data))  {
+            if (!is_null($this->data)) {
+                return $this->data->to(); /*class*/
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this TopLevel::data');
+    }
+
+    /**
+     * @param Data|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateData(?Data $value): bool {
+        if (!is_null($value)) {
+            $value->validate();
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?Data
+     */
+    public function getData(): ?Data {
+        if (TopLevel::validateData($this->data))  {
+            return $this->data;
+        }
+        throw new Exception('never get to getData TopLevel::data');
+    }
+
+    /**
+     * @return ?Data
+     */
+    public static function sampleData(): ?Data {
+        return Data::sample(); /*31:data*/
+    }
+
+    /**
+     * @param ?array $value
+     * @throws Exception
+     * @return ?array
+     */
+    public static function fromErrors(?array $value): ?array {
+        if (!is_null($value)) {
+            return  array_map(function ($value) {
+                return Error::from($value); /*class*/
+            }, $value);
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?array
+     */
+    public function toErrors(): ?array {
+        if (TopLevel::validateErrors($this->errors))  {
+            if (!is_null($this->errors)) {
+                return array_map(function ($value) {
+                    return $value->to(); /*class*/
+                }, $this->errors);
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this TopLevel::errors');
+    }
+
+    /**
+     * @param array|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateErrors(?array $value): bool {
+        if (!is_null($value)) {
+            if (!is_array($value)) {
+                throw new Exception("Attribute Error:TopLevel::errors");
+            }
+            array_walk($value, function($value_v) {
+                $value_v->validate();
+            });
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?array
+     */
+    public function getErrors(): ?array {
+        if (TopLevel::validateErrors($this->errors))  {
+            return $this->errors;
+        }
+        throw new Exception('never get to getErrors TopLevel::errors');
+    }
+
+    /**
+     * @return ?array
+     */
+    public static function sampleErrors(): ?array {
+        return  array(
+            Error::sample() /*32:*/
+        ); /* 32:errors*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return TopLevel::validateData($this->data)
+        || TopLevel::validateErrors($this->errors);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'data'} = $this->toData();
+        $out->{'errors'} = $this->toErrors();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return TopLevel
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): TopLevel {
+        return new TopLevel(
+         TopLevel::fromData($obj->{'data'})
+        ,TopLevel::fromErrors($obj->{'errors'})
+        );
+    }
+
+    /**
+     * @return TopLevel
+     */
+    public static function sample(): TopLevel {
+        return new TopLevel(
+         TopLevel::sampleData()
+        ,TopLevel::sampleErrors()
+        );
+    }
+}
+
+// This is an autogenerated file:Data
+
+class Data {
+    private ?Grid $grid; // json:grid Optional
+
+    /**
+     * @param Grid|null $grid
+     */
+    public function __construct(?Grid $grid) {
+        $this->grid = $grid;
+    }
+
+    /**
+     * @param ?stdClass $value
+     * @throws Exception
+     * @return ?Grid
+     */
+    public static function fromGrid(?stdClass $value): ?Grid {
+        if (!is_null($value)) {
+            return Grid::from($value); /*class*/
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?stdClass
+     */
+    public function toGrid(): ?stdClass {
+        if (Data::validateGrid($this->grid))  {
+            if (!is_null($this->grid)) {
+                return $this->grid->to(); /*class*/
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this Data::grid');
+    }
+
+    /**
+     * @param Grid|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateGrid(?Grid $value): bool {
+        if (!is_null($value)) {
+            $value->validate();
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?Grid
+     */
+    public function getGrid(): ?Grid {
+        if (Data::validateGrid($this->grid))  {
+            return $this->grid;
+        }
+        throw new Exception('never get to getGrid Data::grid');
+    }
+
+    /**
+     * @return ?Grid
+     */
+    public static function sampleGrid(): ?Grid {
+        return Grid::sample(); /*31:grid*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return Data::validateGrid($this->grid);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'grid'} = $this->toGrid();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return Data
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): Data {
+        return new Data(
+         Data::fromGrid($obj->{'grid'})
+        );
+    }
+
+    /**
+     * @return Data
+     */
+    public static function sample(): Data {
+        return new Data(
+         Data::sampleGrid()
+        );
+    }
+}
+
+// This is an autogenerated file:Grid
+
+class Grid {
+    private ?GridConfig $config; // json:config Optional
+    private ?GridProps $props; // json:props Optional
+
+    /**
+     * @param GridConfig|null $config
+     * @param GridProps|null $props
+     */
+    public function __construct(?GridConfig $config, ?GridProps $props) {
+        $this->config = $config;
+        $this->props = $props;
+    }
+
+    /**
+     * @param ?stdClass $value
+     * @throws Exception
+     * @return ?GridConfig
+     */
+    public static function fromConfig(?stdClass $value): ?GridConfig {
+        if (!is_null($value)) {
+            return GridConfig::from($value); /*class*/
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?stdClass
+     */
+    public function toConfig(): ?stdClass {
+        if (Grid::validateConfig($this->config))  {
+            if (!is_null($this->config)) {
+                return $this->config->to(); /*class*/
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this Grid::config');
+    }
+
+    /**
+     * @param GridConfig|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateConfig(?GridConfig $value): bool {
+        if (!is_null($value)) {
+            $value->validate();
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?GridConfig
+     */
+    public function getConfig(): ?GridConfig {
+        if (Grid::validateConfig($this->config))  {
+            return $this->config;
+        }
+        throw new Exception('never get to getConfig Grid::config');
+    }
+
+    /**
+     * @return ?GridConfig
+     */
+    public static function sampleConfig(): ?GridConfig {
+        return GridConfig::sample(); /*31:config*/
+    }
+
+    /**
+     * @param ?stdClass $value
+     * @throws Exception
+     * @return ?GridProps
+     */
+    public static function fromProps(?stdClass $value): ?GridProps {
+        if (!is_null($value)) {
+            return GridProps::from($value); /*class*/
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?stdClass
+     */
+    public function toProps(): ?stdClass {
+        if (Grid::validateProps($this->props))  {
+            if (!is_null($this->props)) {
+                return $this->props->to(); /*class*/
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this Grid::props');
+    }
+
+    /**
+     * @param GridProps|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateProps(?GridProps $value): bool {
+        if (!is_null($value)) {
+            $value->validate();
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?GridProps
+     */
+    public function getProps(): ?GridProps {
+        if (Grid::validateProps($this->props))  {
+            return $this->props;
+        }
+        throw new Exception('never get to getProps Grid::props');
+    }
+
+    /**
+     * @return ?GridProps
+     */
+    public static function sampleProps(): ?GridProps {
+        return GridProps::sample(); /*32:props*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return Grid::validateConfig($this->config)
+        || Grid::validateProps($this->props);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'config'} = $this->toConfig();
+        $out->{'props'} = $this->toProps();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return Grid
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): Grid {
+        return new Grid(
+         Grid::fromConfig($obj->{'config'})
+        ,Grid::fromProps($obj->{'props'})
+        );
+    }
+
+    /**
+     * @return Grid
+     */
+    public static function sample(): Grid {
+        return new Grid(
+         Grid::sampleConfig()
+        ,Grid::sampleProps()
+        );
+    }
+}
+
+// This is an autogenerated file:GridConfig
+
+class GridConfig {
+    private ?array $items; // json:items Optional
+
+    /**
+     * @param array|null $items
+     */
+    public function __construct(?array $items) {
+        $this->items = $items;
+    }
+
+    /**
+     * @param ?array $value
+     * @throws Exception
+     * @return ?array
+     */
+    public static function fromItems(?array $value): ?array {
+        if (!is_null($value)) {
+            return  array_map(function ($value) {
+                if (!is_null($value)) {
+                    return ComponentRef::from($value); /*class*/
+                } else {
+                    return  null;
+                }
+            }, $value);
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?array
+     */
+    public function toItems(): ?array {
+        if (GridConfig::validateItems($this->items))  {
+            if (!is_null($this->items)) {
+                return array_map(function ($value) {
+                    if (!is_null($value)) {
+                        return $value->to(); /*class*/
+                    } else {
+                        return  null;
+                    }
+                }, $this->items);
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this GridConfig::items');
+    }
+
+    /**
+     * @param array|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateItems(?array $value): bool {
+        if (!is_null($value)) {
+            if (!is_array($value)) {
+                throw new Exception("Attribute Error:GridConfig::items");
+            }
+            array_walk($value, function($value_v) {
+                if (!is_null($value_v)) {
+                    $value_v->validate();
+                }
+            });
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?array
+     */
+    public function getItems(): ?array {
+        if (GridConfig::validateItems($this->items))  {
+            return $this->items;
+        }
+        throw new Exception('never get to getItems GridConfig::items');
+    }
+
+    /**
+     * @return ?array
+     */
+    public static function sampleItems(): ?array {
+        return  array(
+            ComponentRef::sample() /*31:*/
+        ); /* 31:items*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return GridConfig::validateItems($this->items);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'items'} = $this->toItems();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return GridConfig
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): GridConfig {
+        return new GridConfig(
+         GridConfig::fromItems($obj->{'items'})
+        );
+    }
+
+    /**
+     * @return GridConfig
+     */
+    public static function sample(): GridConfig {
+        return new GridConfig(
+         GridConfig::sampleItems()
+        );
+    }
+}
+
+// This is an autogenerated file:ComponentRef
+
+class ComponentRef {
+    private ?string $id; // json:id Optional
+
+    /**
+     * @param string|null $id
+     */
+    public function __construct(?string $id) {
+        $this->id = $id;
+    }
+
+    /**
+     * @param ?string $value
+     * @throws Exception
+     * @return ?string
+     */
+    public static function fromID(?string $value): ?string {
+        if (!is_null($value)) {
+            return $value; /*string*/
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?string
+     */
+    public function toID(): ?string {
+        if (ComponentRef::validateID($this->id))  {
+            if (!is_null($this->id)) {
+                return $this->id; /*string*/
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this ComponentRef::id');
+    }
+
+    /**
+     * @param string|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateID(?string $value): bool {
+        if (!is_null($value)) {
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?string
+     */
+    public function getID(): ?string {
+        if (ComponentRef::validateID($this->id))  {
+            return $this->id;
+        }
+        throw new Exception('never get to getID ComponentRef::id');
+    }
+
+    /**
+     * @return ?string
+     */
+    public static function sampleID(): ?string {
+        return 'ComponentRef::id::31'; /*31:id*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return ComponentRef::validateID($this->id);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'id'} = $this->toID();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return ComponentRef
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): ComponentRef {
+        return new ComponentRef(
+         ComponentRef::fromID($obj->{'id'})
+        );
+    }
+
+    /**
+     * @return ComponentRef
+     */
+    public static function sample(): ComponentRef {
+        return new ComponentRef(
+         ComponentRef::sampleID()
+        );
+    }
+}
+
+// This is an autogenerated file:GridProps
+
+class GridProps {
+    private ?array $items; // json:items Optional
+
+    /**
+     * @param array|null $items
+     */
+    public function __construct(?array $items) {
+        $this->items = $items;
+    }
+
+    /**
+     * @param ?array $value
+     * @throws Exception
+     * @return ?array
+     */
+    public static function fromItems(?array $value): ?array {
+        if (!is_null($value)) {
+            return  array_map(function ($value) {
+                if (!is_null($value)) {
+                    return ComponentRef::from($value); /*class*/
+                } else {
+                    return  null;
+                }
+            }, $value);
+        } else {
+            return  null;
+        }
+    }
+
+    /**
+     * @throws Exception
+     * @return ?array
+     */
+    public function toItems(): ?array {
+        if (GridProps::validateItems($this->items))  {
+            if (!is_null($this->items)) {
+                return array_map(function ($value) {
+                    if (!is_null($value)) {
+                        return $value->to(); /*class*/
+                    } else {
+                        return  null;
+                    }
+                }, $this->items);
+            } else {
+                return  null;
+            }
+        }
+        throw new Exception('never get to this GridProps::items');
+    }
+
+    /**
+     * @param array|null
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateItems(?array $value): bool {
+        if (!is_null($value)) {
+            if (!is_array($value)) {
+                throw new Exception("Attribute Error:GridProps::items");
+            }
+            array_walk($value, function($value_v) {
+                if (!is_null($value_v)) {
+                    $value_v->validate();
+                }
+            });
+        }
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return ?array
+     */
+    public function getItems(): ?array {
+        if (GridProps::validateItems($this->items))  {
+            return $this->items;
+        }
+        throw new Exception('never get to getItems GridProps::items');
+    }
+
+    /**
+     * @return ?array
+     */
+    public static function sampleItems(): ?array {
+        return  array(
+            ComponentRef::sample() /*31:*/
+        ); /* 31:items*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return GridProps::validateItems($this->items);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'items'} = $this->toItems();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return GridProps
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): GridProps {
+        return new GridProps(
+         GridProps::fromItems($obj->{'items'})
+        );
+    }
+
+    /**
+     * @return GridProps
+     */
+    public static function sample(): GridProps {
+        return new GridProps(
+         GridProps::sampleItems()
+        );
+    }
+}
+
+// This is an autogenerated file:Error
+
+class Error {
+    private string $message; // json:message Required
+
+    /**
+     * @param string $message
+     */
+    public function __construct(string $message) {
+        $this->message = $message;
+    }
+
+    /**
+     * @param string $value
+     * @throws Exception
+     * @return string
+     */
+    public static function fromMessage(string $value): string {
+        return $value; /*string*/
+    }
+
+    /**
+     * @throws Exception
+     * @return string
+     */
+    public function toMessage(): string {
+        if (Error::validateMessage($this->message))  {
+            return $this->message; /*string*/
+        }
+        throw new Exception('never get to this Error::message');
+    }
+
+    /**
+     * @param string
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateMessage(string $value): bool {
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return string
+     */
+    public function getMessage(): string {
+        if (Error::validateMessage($this->message))  {
+            return $this->message;
+        }
+        throw new Exception('never get to getMessage Error::message');
+    }
+
+    /**
+     * @return string
+     */
+    public static function sampleMessage(): string {
+        return 'Error::message::31'; /*31:message*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return Error::validateMessage($this->message);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'message'} = $this->toMessage();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return Error
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): Error {
+        return new Error(
+         Error::fromMessage($obj->{'message'})
+        );
+    }
+
+    /**
+     * @return Error
+     */
+    public static function sample(): Error {
+        return new Error(
+         Error::sampleMessage()
+        );
+    }
+}
diff --git a/base/graphql-pike/test/inputs/graphql/github7.graphql/default/TopLevel.pmod b/head/graphql-pike/test/inputs/graphql/github7.graphql/default/TopLevel.pmod
index 677fdea..b9db7ce 100644
--- a/base/graphql-pike/test/inputs/graphql/github7.graphql/default/TopLevel.pmod
+++ b/head/graphql-pike/test/inputs/graphql/github7.graphql/default/TopLevel.pmod
@@ -56,9 +56,9 @@ Data Data_from_JSON(mixed json) {
 }
 
 class User {
-    string               login;                // json: "login"
-    Connection           starred_repositories; // json: "starredRepositories"
-    RepositoryConnection repositories;         // json: "repositories"
+    string                      login;                // json: "login"
+    StarredRepositoryConnection starred_repositories; // json: "starredRepositories"
+    UserRepositoryConnection    repositories;         // json: "repositories"
 
     string encode_json() {
         mapping(string:mixed) json = ([
@@ -81,7 +81,7 @@ User User_from_JSON(mixed json) {
     return retval;
 }
 
-class RepositoryConnection {
+class UserRepositoryConnection {
     array(RepositoryEdge|mixed)|mixed edges; // json: "edges"
 
     string encode_json() {
@@ -93,8 +93,8 @@ class RepositoryConnection {
     }
 }
 
-RepositoryConnection RepositoryConnection_from_JSON(mixed json) {
-    RepositoryConnection retval = RepositoryConnection();
+UserRepositoryConnection UserRepositoryConnection_from_JSON(mixed json) {
+    UserRepositoryConnection retval = UserRepositoryConnection();
 
     retval.edges = json["edges"];
 
@@ -122,11 +122,11 @@ RepositoryEdge RepositoryEdge_from_JSON(mixed json) {
 }
 
 class Repository {
-    string     name;       // json: "name"
-    Connection stargazers; // json: "stargazers"
-    Connection forks;      // json: "forks"
-    Connection watchers;   // json: "watchers"
-    Connection issues;     // json: "issues"
+    string                         name;       // json: "name"
+    StargazerConnection            stargazers; // json: "stargazers"
+    RepositoryRepositoryConnection forks;      // json: "forks"
+    UserConnection                 watchers;   // json: "watchers"
+    IssueConnection                issues;     // json: "issues"
 
     string encode_json() {
         mapping(string:mixed) json = ([
@@ -153,7 +153,7 @@ Repository Repository_from_JSON(mixed json) {
     return retval;
 }
 
-class Connection {
+class RepositoryRepositoryConnection {
     int total_count; // json: "totalCount"
 
     string encode_json() {
@@ -165,8 +165,88 @@ class Connection {
     }
 }
 
-Connection Connection_from_JSON(mixed json) {
-    Connection retval = Connection();
+RepositoryRepositoryConnection RepositoryRepositoryConnection_from_JSON(mixed json) {
+    RepositoryRepositoryConnection retval = RepositoryRepositoryConnection();
+
+    retval.total_count = json["totalCount"];
+
+    return retval;
+}
+
+class IssueConnection {
+    int total_count; // json: "totalCount"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "totalCount" : total_count,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+IssueConnection IssueConnection_from_JSON(mixed json) {
+    IssueConnection retval = IssueConnection();
+
+    retval.total_count = json["totalCount"];
+
+    return retval;
+}
+
+class StargazerConnection {
+    int total_count; // json: "totalCount"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "totalCount" : total_count,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+StargazerConnection StargazerConnection_from_JSON(mixed json) {
+    StargazerConnection retval = StargazerConnection();
+
+    retval.total_count = json["totalCount"];
+
+    return retval;
+}
+
+class UserConnection {
+    int total_count; // json: "totalCount"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "totalCount" : total_count,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+UserConnection UserConnection_from_JSON(mixed json) {
+    UserConnection retval = UserConnection();
+
+    retval.total_count = json["totalCount"];
+
+    return retval;
+}
+
+class StarredRepositoryConnection {
+    int total_count; // json: "totalCount"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "totalCount" : total_count,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+StarredRepositoryConnection StarredRepositoryConnection_from_JSON(mixed json) {
+    StarredRepositoryConnection retval = StarredRepositoryConnection();
 
     retval.total_count = json["totalCount"];
 
diff --git a/base/graphql-pike/test/inputs/graphql/github9.graphql/default/TopLevel.pmod b/head/graphql-pike/test/inputs/graphql/github9.graphql/default/TopLevel.pmod
index 94ae37a..e905309 100644
--- a/base/graphql-pike/test/inputs/graphql/github9.graphql/default/TopLevel.pmod
+++ b/head/graphql-pike/test/inputs/graphql/github9.graphql/default/TopLevel.pmod
@@ -111,8 +111,8 @@ enum ReactionContent {
 }
 
 class Reactable {
-    bool                  viewer_can_react; // json: "viewerCanReact"
-    array(Reaction)|mixed reaction_groups;  // json: "reactionGroups"
+    bool                       viewer_can_react; // json: "viewerCanReact"
+    array(ReactionGroup)|mixed reaction_groups;  // json: "reactionGroups"
 
     string encode_json() {
         mapping(string:mixed) json = ([
@@ -133,6 +133,26 @@ Reactable Reactable_from_JSON(mixed json) {
     return retval;
 }
 
+class ReactionGroup {
+    ReactionContent content; // json: "content"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "content" : content,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+ReactionGroup ReactionGroup_from_JSON(mixed json) {
+    ReactionGroup retval = ReactionGroup();
+
+    retval.content = json["content"];
+
+    return retval;
+}
+
 class Error {
     string message; // json: "message"
 
diff --git a/head/graphql-pike/test/inputs/graphql/separate-types1.graphql/default/TopLevel.pmod b/head/graphql-pike/test/inputs/graphql/separate-types1.graphql/default/TopLevel.pmod
new file mode 100644
index 0000000..282f21e
--- /dev/null
+++ b/head/graphql-pike/test/inputs/graphql/separate-types1.graphql/default/TopLevel.pmod
@@ -0,0 +1,159 @@
+// This source has been automatically generated by quicktype.
+// ( https://github.com/quicktype/quicktype )
+//
+// To use this code, simply import it into your project as a Pike module.
+// To JSON-encode your object, you can pass it to `Standards.JSON.encode`
+// or call `encode_json` on it.
+//
+// To decode a JSON string, first pass it to `Standards.JSON.decode`,
+// and then pass the result to `<YourClass>_from_JSON`.
+// It will return an instance of <YourClass>.
+// Bear in mind that these functions have unexpected behavior,
+// and will likely throw an error, if the JSON string does not
+// match the expected interface, even if the JSON itself is valid.
+
+class TopLevel {
+    Data|mixed         data;   // json: "data"
+    array(Error)|mixed errors; // json: "errors"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "data" : data,
+            "errors" : errors,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+TopLevel TopLevel_from_JSON(mixed json) {
+    TopLevel retval = TopLevel();
+
+    retval.data = json["data"];
+    retval.errors = json["errors"];
+
+    return retval;
+}
+
+class Data {
+    Grid|mixed grid; // json: "grid"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "grid" : grid,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+Data Data_from_JSON(mixed json) {
+    Data retval = Data();
+
+    retval.grid = json["grid"];
+
+    return retval;
+}
+
+class Grid {
+    GridConfig|mixed config; // json: "config"
+    GridProps|mixed  props;  // json: "props"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "config" : config,
+            "props" : props,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+Grid Grid_from_JSON(mixed json) {
+    Grid retval = Grid();
+
+    retval.config = json["config"];
+    retval.props = json["props"];
+
+    return retval;
+}
+
+class GridConfig {
+    array(ComponentRef|mixed)|mixed items; // json: "items"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "items" : items,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+GridConfig GridConfig_from_JSON(mixed json) {
+    GridConfig retval = GridConfig();
+
+    retval.items = json["items"];
+
+    return retval;
+}
+
+class ComponentRef {
+    mixed|string id; // json: "id"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "id" : id,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+ComponentRef ComponentRef_from_JSON(mixed json) {
+    ComponentRef retval = ComponentRef();
+
+    retval.id = json["id"];
+
+    return retval;
+}
+
+class GridProps {
+    array(ComponentRef|mixed)|mixed items; // json: "items"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "items" : items,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+GridProps GridProps_from_JSON(mixed json) {
+    GridProps retval = GridProps();
+
+    retval.items = json["items"];
+
+    return retval;
+}
+
+class Error {
+    string message; // json: "message"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "message" : message,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+Error Error_from_JSON(mixed json) {
+    Error retval = Error();
+
+    retval.message = json["message"];
+
+    return retval;
+}
diff --git a/base/graphql-python/test/inputs/graphql/github7.graphql/default/quicktype.py b/head/graphql-python/test/inputs/graphql/github7.graphql/default/quicktype.py
index 6e460ec..cff5f65 100644
--- a/base/graphql-python/test/inputs/graphql/github7.graphql/default/quicktype.py
+++ b/head/graphql-python/test/inputs/graphql/github7.graphql/default/quicktype.py
@@ -40,14 +40,62 @@ def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
 
 
 @dataclass
-class Connection:
+class RepositoryRepositoryConnection:
     total_count: int
 
     @staticmethod
-    def from_dict(obj: Any) -> 'Connection':
+    def from_dict(obj: Any) -> 'RepositoryRepositoryConnection':
         assert isinstance(obj, dict)
         total_count = from_int(obj.get("totalCount"))
-        return Connection(total_count)
+        return RepositoryRepositoryConnection(total_count)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["totalCount"] = from_int(self.total_count)
+        return result
+
+
+@dataclass
+class IssueConnection:
+    total_count: int
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'IssueConnection':
+        assert isinstance(obj, dict)
+        total_count = from_int(obj.get("totalCount"))
+        return IssueConnection(total_count)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["totalCount"] = from_int(self.total_count)
+        return result
+
+
+@dataclass
+class StargazerConnection:
+    total_count: int
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'StargazerConnection':
+        assert isinstance(obj, dict)
+        total_count = from_int(obj.get("totalCount"))
+        return StargazerConnection(total_count)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["totalCount"] = from_int(self.total_count)
+        return result
+
+
+@dataclass
+class UserConnection:
+    total_count: int
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'UserConnection':
+        assert isinstance(obj, dict)
+        total_count = from_int(obj.get("totalCount"))
+        return UserConnection(total_count)
 
     def to_dict(self) -> dict:
         result: dict = {}
@@ -58,28 +106,28 @@ class Connection:
 @dataclass
 class Repository:
     name: str
-    stargazers: Connection
-    forks: Connection
-    watchers: Connection
-    issues: Connection
+    stargazers: StargazerConnection
+    forks: RepositoryRepositoryConnection
+    watchers: UserConnection
+    issues: IssueConnection
 
     @staticmethod
     def from_dict(obj: Any) -> 'Repository':
         assert isinstance(obj, dict)
         name = from_str(obj.get("name"))
-        stargazers = Connection.from_dict(obj.get("stargazers"))
-        forks = Connection.from_dict(obj.get("forks"))
-        watchers = Connection.from_dict(obj.get("watchers"))
-        issues = Connection.from_dict(obj.get("issues"))
+        stargazers = StargazerConnection.from_dict(obj.get("stargazers"))
+        forks = RepositoryRepositoryConnection.from_dict(obj.get("forks"))
+        watchers = UserConnection.from_dict(obj.get("watchers"))
+        issues = IssueConnection.from_dict(obj.get("issues"))
         return Repository(name, stargazers, forks, watchers, issues)
 
     def to_dict(self) -> dict:
         result: dict = {}
         result["name"] = from_str(self.name)
-        result["stargazers"] = to_class(Connection, self.stargazers)
-        result["forks"] = to_class(Connection, self.forks)
-        result["watchers"] = to_class(Connection, self.watchers)
-        result["issues"] = to_class(Connection, self.issues)
+        result["stargazers"] = to_class(StargazerConnection, self.stargazers)
+        result["forks"] = to_class(RepositoryRepositoryConnection, self.forks)
+        result["watchers"] = to_class(UserConnection, self.watchers)
+        result["issues"] = to_class(IssueConnection, self.issues)
         return result
 
 
@@ -100,14 +148,14 @@ class RepositoryEdge:
 
 
 @dataclass
-class RepositoryConnection:
+class UserRepositoryConnection:
     edges: list[RepositoryEdge | None] | None = None
 
     @staticmethod
-    def from_dict(obj: Any) -> 'RepositoryConnection':
+    def from_dict(obj: Any) -> 'UserRepositoryConnection':
         assert isinstance(obj, dict)
         edges = from_union([lambda x: from_list(lambda x: from_union([RepositoryEdge.from_dict, from_none], x), x), from_none], obj.get("edges"))
-        return RepositoryConnection(edges)
+        return UserRepositoryConnection(edges)
 
     def to_dict(self) -> dict:
         result: dict = {}
@@ -115,25 +163,41 @@ class RepositoryConnection:
         return result
 
 
+@dataclass
+class StarredRepositoryConnection:
+    total_count: int
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'StarredRepositoryConnection':
+        assert isinstance(obj, dict)
+        total_count = from_int(obj.get("totalCount"))
+        return StarredRepositoryConnection(total_count)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["totalCount"] = from_int(self.total_count)
+        return result
+
+
 @dataclass
 class User:
     login: str
-    starred_repositories: Connection
-    repositories: RepositoryConnection
+    starred_repositories: StarredRepositoryConnection
+    repositories: UserRepositoryConnection
 
     @staticmethod
     def from_dict(obj: Any) -> 'User':
         assert isinstance(obj, dict)
         login = from_str(obj.get("login"))
-        starred_repositories = Connection.from_dict(obj.get("starredRepositories"))
-        repositories = RepositoryConnection.from_dict(obj.get("repositories"))
+        starred_repositories = StarredRepositoryConnection.from_dict(obj.get("starredRepositories"))
+        repositories = UserRepositoryConnection.from_dict(obj.get("repositories"))
         return User(login, starred_repositories, repositories)
 
     def to_dict(self) -> dict:
         result: dict = {}
         result["login"] = from_str(self.login)
-        result["starredRepositories"] = to_class(Connection, self.starred_repositories)
-        result["repositories"] = to_class(RepositoryConnection, self.repositories)
+        result["starredRepositories"] = to_class(StarredRepositoryConnection, self.starred_repositories)
+        result["repositories"] = to_class(UserRepositoryConnection, self.repositories)
         return result
 
 
diff --git a/base/graphql-python/test/inputs/graphql/github9.graphql/default/quicktype.py b/head/graphql-python/test/inputs/graphql/github9.graphql/default/quicktype.py
index 5b52a64..cefaddb 100644
--- a/base/graphql-python/test/inputs/graphql/github9.graphql/default/quicktype.py
+++ b/head/graphql-python/test/inputs/graphql/github9.graphql/default/quicktype.py
@@ -71,22 +71,38 @@ class Reaction:
         return result
 
 
+@dataclass
+class ReactionGroup:
+    content: ReactionContent
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'ReactionGroup':
+        assert isinstance(obj, dict)
+        content = ReactionContent(obj.get("content"))
+        return ReactionGroup(content)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["content"] = to_enum(ReactionContent, self.content)
+        return result
+
+
 @dataclass
 class Reactable:
     viewer_can_react: bool
-    reaction_groups: list[Reaction] | None = None
+    reaction_groups: list[ReactionGroup] | None = None
 
     @staticmethod
     def from_dict(obj: Any) -> 'Reactable':
         assert isinstance(obj, dict)
         viewer_can_react = from_bool(obj.get("viewerCanReact"))
-        reaction_groups = from_union([lambda x: from_list(Reaction.from_dict, x), from_none], obj.get("reactionGroups"))
+        reaction_groups = from_union([lambda x: from_list(ReactionGroup.from_dict, x), from_none], obj.get("reactionGroups"))
         return Reactable(viewer_can_react, reaction_groups)
 
     def to_dict(self) -> dict:
         result: dict = {}
         result["viewerCanReact"] = from_bool(self.viewer_can_react)
-        result["reactionGroups"] = from_union([lambda x: from_list(lambda x: to_class(Reaction, x), x), from_none], self.reaction_groups)
+        result["reactionGroups"] = from_union([lambda x: from_list(lambda x: to_class(ReactionGroup, x), x), from_none], self.reaction_groups)
         return result
 
 
diff --git a/head/graphql-python/test/inputs/graphql/separate-types1.graphql/default/quicktype.py b/head/graphql-python/test/inputs/graphql/separate-types1.graphql/default/quicktype.py
new file mode 100644
index 0000000..b717dc3
--- /dev/null
+++ b/head/graphql-python/test/inputs/graphql/separate-types1.graphql/default/quicktype.py
@@ -0,0 +1,161 @@
+from dataclasses import dataclass
+from typing import Any, TypeVar, Callable, Type, cast
+
+
+T = TypeVar("T")
+
+
+def from_str(x: Any) -> str:
+    assert isinstance(x, str)
+    return x
+
+
+def from_none(x: Any) -> Any:
+    assert x is None
+    return x
+
+
+def from_union(fs, x):
+    for f in fs:
+        try:
+            return f(x)
+        except:
+            pass
+    assert False
+
+
+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
+    assert isinstance(x, list)
+    return [f(y) for y in x]
+
+
+def to_class(c: Type[T], x: Any) -> dict:
+    assert isinstance(x, c)
+    return cast(Any, x).to_dict()
+
+
+@dataclass
+class ComponentRef:
+    id: str | None = None
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'ComponentRef':
+        assert isinstance(obj, dict)
+        id = from_union([from_str, from_none], obj.get("id"))
+        return ComponentRef(id)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["id"] = from_union([from_str, from_none], self.id)
+        return result
+
+
+@dataclass
+class GridConfig:
+    items: list[ComponentRef | None] | None = None
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'GridConfig':
+        assert isinstance(obj, dict)
+        items = from_union([lambda x: from_list(lambda x: from_union([ComponentRef.from_dict, from_none], x), x), from_none], obj.get("items"))
+        return GridConfig(items)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["items"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: to_class(ComponentRef, x), from_none], x), x), from_none], self.items)
+        return result
+
+
+@dataclass
+class GridProps:
+    items: list[ComponentRef | None] | None = None
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'GridProps':
+        assert isinstance(obj, dict)
+        items = from_union([lambda x: from_list(lambda x: from_union([ComponentRef.from_dict, from_none], x), x), from_none], obj.get("items"))
+        return GridProps(items)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["items"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: to_class(ComponentRef, x), from_none], x), x), from_none], self.items)
+        return result
+
+
+@dataclass
+class Grid:
+    config: GridConfig | None = None
+    props: GridProps | None = None
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'Grid':
+        assert isinstance(obj, dict)
+        config = from_union([GridConfig.from_dict, from_none], obj.get("config"))
+        props = from_union([GridProps.from_dict, from_none], obj.get("props"))
+        return Grid(config, props)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["config"] = from_union([lambda x: to_class(GridConfig, x), from_none], self.config)
+        result["props"] = from_union([lambda x: to_class(GridProps, x), from_none], self.props)
+        return result
+
+
+@dataclass
+class Data:
+    grid: Grid | None = None
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'Data':
+        assert isinstance(obj, dict)
+        grid = from_union([Grid.from_dict, from_none], obj.get("grid"))
+        return Data(grid)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["grid"] = from_union([lambda x: to_class(Grid, x), from_none], self.grid)
+        return result
+
+
+@dataclass
+class Error:
+    message: str
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'Error':
+        assert isinstance(obj, dict)
+        message = from_str(obj.get("message"))
+        return Error(message)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["message"] = from_str(self.message)
+        return result
+
+
+@dataclass
+class TopLevel:
+    data: Data | None = None
+    errors: list[Error] | None = None
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'TopLevel':
+        assert isinstance(obj, dict)
+        data = from_union([Data.from_dict, from_none], obj.get("data"))
+        errors = from_union([lambda x: from_list(Error.from_dict, x), from_none], obj.get("errors"))
+        return TopLevel(data, errors)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["data"] = from_union([lambda x: to_class(Data, x), from_none], self.data)
+        if self.errors is not None:
+            result["errors"] = from_union([lambda x: from_list(lambda x: to_class(Error, x), x), from_none], self.errors)
+        return result
+
+
+def top_level_from_dict(s: Any) -> TopLevel:
+    return TopLevel.from_dict(s)
+
+
+def top_level_to_dict(x: TopLevel) -> Any:
+    return to_class(TopLevel, x)
diff --git a/base/graphql-swift/test/inputs/graphql/github7.graphql/default/quicktype.swift b/head/graphql-swift/test/inputs/graphql/github7.graphql/default/quicktype.swift
index 22861b6..ab6e308 100644
--- a/base/graphql-swift/test/inputs/graphql/github7.graphql/default/quicktype.swift
+++ b/head/graphql-swift/test/inputs/graphql/github7.graphql/default/quicktype.swift
@@ -100,8 +100,8 @@ extension DataClass {
 // MARK: - User
 struct User: Codable {
     let login: String
-    let starredRepositories: Connection
-    let repositories: RepositoryConnection
+    let starredRepositories: StarredRepositoryConnection
+    let repositories: UserRepositoryConnection
 
     enum CodingKeys: String, CodingKey {
         case login = "login"
@@ -130,8 +130,8 @@ extension User {
 
     func with(
         login: String? = nil,
-        starredRepositories: Connection? = nil,
-        repositories: RepositoryConnection? = nil
+        starredRepositories: StarredRepositoryConnection? = nil,
+        repositories: UserRepositoryConnection? = nil
     ) -> User {
         return User(
             login: login ?? self.login,
@@ -149,8 +149,8 @@ extension User {
     }
 }
 
-// MARK: - RepositoryConnection
-struct RepositoryConnection: Codable {
+// MARK: - UserRepositoryConnection
+struct UserRepositoryConnection: Codable {
     let edges: [RepositoryEdge?]?
 
     enum CodingKeys: String, CodingKey {
@@ -158,11 +158,11 @@ struct RepositoryConnection: Codable {
     }
 }
 
-// MARK: RepositoryConnection convenience initializers and mutators
+// MARK: UserRepositoryConnection convenience initializers and mutators
 
-extension RepositoryConnection {
+extension UserRepositoryConnection {
     init(data: Data) throws {
-        self = try newJSONDecoder().decode(RepositoryConnection.self, from: data)
+        self = try newJSONDecoder().decode(UserRepositoryConnection.self, from: data)
     }
 
     init(_ json: String, using encoding: String.Encoding = .utf8) throws {
@@ -178,8 +178,8 @@ extension RepositoryConnection {
 
     func with(
         edges: [RepositoryEdge?]?? = nil
-    ) -> RepositoryConnection {
-        return RepositoryConnection(
+    ) -> UserRepositoryConnection {
+        return UserRepositoryConnection(
             edges: edges ?? self.edges
         )
     }
@@ -240,10 +240,10 @@ extension RepositoryEdge {
 // MARK: - Repository
 struct Repository: Codable {
     let name: String
-    let stargazers: Connection
-    let forks: Connection
-    let watchers: Connection
-    let issues: Connection
+    let stargazers: StargazerConnection
+    let forks: RepositoryRepositoryConnection
+    let watchers: UserConnection
+    let issues: IssueConnection
 
     enum CodingKeys: String, CodingKey {
         case name = "name"
@@ -274,10 +274,10 @@ extension Repository {
 
     func with(
         name: String? = nil,
-        stargazers: Connection? = nil,
-        forks: Connection? = nil,
-        watchers: Connection? = nil,
-        issues: Connection? = nil
+        stargazers: StargazerConnection? = nil,
+        forks: RepositoryRepositoryConnection? = nil,
+        watchers: UserConnection? = nil,
+        issues: IssueConnection? = nil
     ) -> Repository {
         return Repository(
             name: name ?? self.name,
@@ -297,8 +297,8 @@ extension Repository {
     }
 }
 
-// MARK: - Connection
-struct Connection: Codable {
+// MARK: - RepositoryRepositoryConnection
+struct RepositoryRepositoryConnection: Codable {
     let totalCount: Int
 
     enum CodingKeys: String, CodingKey {
@@ -306,11 +306,11 @@ struct Connection: Codable {
     }
 }
 
-// MARK: Connection convenience initializers and mutators
+// MARK: RepositoryRepositoryConnection convenience initializers and mutators
 
-extension Connection {
+extension RepositoryRepositoryConnection {
     init(data: Data) throws {
-        self = try newJSONDecoder().decode(Connection.self, from: data)
+        self = try newJSONDecoder().decode(RepositoryRepositoryConnection.self, from: data)
     }
 
     init(_ json: String, using encoding: String.Encoding = .utf8) throws {
@@ -326,8 +326,184 @@ extension Connection {
 
     func with(
         totalCount: Int? = nil
-    ) -> Connection {
-        return Connection(
+    ) -> RepositoryRepositoryConnection {
+        return RepositoryRepositoryConnection(
+            totalCount: totalCount ?? self.totalCount
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - IssueConnection
+struct IssueConnection: Codable {
+    let totalCount: Int
+
+    enum CodingKeys: String, CodingKey {
+        case totalCount = "totalCount"
+    }
+}
+
+// MARK: IssueConnection convenience initializers and mutators
+
+extension IssueConnection {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(IssueConnection.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        totalCount: Int? = nil
+    ) -> IssueConnection {
+        return IssueConnection(
+            totalCount: totalCount ?? self.totalCount
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - StargazerConnection
+struct StargazerConnection: Codable {
+    let totalCount: Int
+
+    enum CodingKeys: String, CodingKey {
+        case totalCount = "totalCount"
+    }
+}
+
+// MARK: StargazerConnection convenience initializers and mutators
+
+extension StargazerConnection {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(StargazerConnection.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        totalCount: Int? = nil
+    ) -> StargazerConnection {
+        return StargazerConnection(
+            totalCount: totalCount ?? self.totalCount
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - UserConnection
+struct UserConnection: Codable {
+    let totalCount: Int
+
+    enum CodingKeys: String, CodingKey {
+        case totalCount = "totalCount"
+    }
+}
+
+// MARK: UserConnection convenience initializers and mutators
+
+extension UserConnection {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(UserConnection.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        totalCount: Int? = nil
+    ) -> UserConnection {
+        return UserConnection(
+            totalCount: totalCount ?? self.totalCount
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - StarredRepositoryConnection
+struct StarredRepositoryConnection: Codable {
+    let totalCount: Int
+
+    enum CodingKeys: String, CodingKey {
+        case totalCount = "totalCount"
+    }
+}
+
+// MARK: StarredRepositoryConnection convenience initializers and mutators
+
+extension StarredRepositoryConnection {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(StarredRepositoryConnection.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        totalCount: Int? = nil
+    ) -> StarredRepositoryConnection {
+        return StarredRepositoryConnection(
             totalCount: totalCount ?? self.totalCount
         )
     }
diff --git a/base/graphql-swift/test/inputs/graphql/github9.graphql/default/quicktype.swift b/head/graphql-swift/test/inputs/graphql/github9.graphql/default/quicktype.swift
index e28b3d9..fe4091f 100644
--- a/base/graphql-swift/test/inputs/graphql/github9.graphql/default/quicktype.swift
+++ b/head/graphql-swift/test/inputs/graphql/github9.graphql/default/quicktype.swift
@@ -205,7 +205,7 @@ enum ReactionContent: String, Codable {
 // MARK: - Reactable
 struct Reactable: Codable {
     let viewerCanReact: Bool
-    let reactionGroups: [Reaction]?
+    let reactionGroups: [ReactionGroup]?
 
     enum CodingKeys: String, CodingKey {
         case viewerCanReact = "viewerCanReact"
@@ -233,7 +233,7 @@ extension Reactable {
 
     func with(
         viewerCanReact: Bool? = nil,
-        reactionGroups: [Reaction]?? = nil
+        reactionGroups: [ReactionGroup]?? = nil
     ) -> Reactable {
         return Reactable(
             viewerCanReact: viewerCanReact ?? self.viewerCanReact,
@@ -250,6 +250,50 @@ extension Reactable {
     }
 }
 
+// MARK: - ReactionGroup
+struct ReactionGroup: Codable {
+    let content: ReactionContent
+
+    enum CodingKeys: String, CodingKey {
+        case content = "content"
+    }
+}
+
+// MARK: ReactionGroup convenience initializers and mutators
+
+extension ReactionGroup {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(ReactionGroup.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        content: ReactionContent? = nil
+    ) -> ReactionGroup {
+        return ReactionGroup(
+            content: content ?? self.content
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
 // MARK: - Error
 struct Error: Codable {
     let message: String
diff --git a/head/graphql-swift/test/inputs/graphql/separate-types1.graphql/default/quicktype.swift b/head/graphql-swift/test/inputs/graphql/separate-types1.graphql/default/quicktype.swift
new file mode 100644
index 0000000..4c1dca1
--- /dev/null
+++ b/head/graphql-swift/test/inputs/graphql/separate-types1.graphql/default/quicktype.swift
@@ -0,0 +1,358 @@
+// This file was generated from JSON Schema using quicktype, do not modify it directly.
+// To parse the JSON, add this file to your project and do:
+//
+//   let topLevel = try TopLevel(json)
+
+import Foundation
+
+// MARK: - TopLevel
+struct TopLevel: Codable {
+    let data: DataClass?
+    let errors: [Error]?
+
+    enum CodingKeys: String, CodingKey {
+        case data = "data"
+        case errors = "errors"
+    }
+}
+
+// MARK: TopLevel convenience initializers and mutators
+
+extension TopLevel {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(TopLevel.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        data: DataClass?? = nil,
+        errors: [Error]?? = nil
+    ) -> TopLevel {
+        return TopLevel(
+            data: data ?? self.data,
+            errors: errors ?? self.errors
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - DataClass
+struct DataClass: Codable {
+    let grid: Grid?
+
+    enum CodingKeys: String, CodingKey {
+        case grid = "grid"
+    }
+}
+
+// MARK: DataClass convenience initializers and mutators
+
+extension DataClass {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(DataClass.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        grid: Grid?? = nil
+    ) -> DataClass {
+        return DataClass(
+            grid: grid ?? self.grid
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - Grid
+struct Grid: Codable {
+    let config: GridConfig?
+    let props: GridProps?
+
+    enum CodingKeys: String, CodingKey {
+        case config = "config"
+        case props = "props"
+    }
+}
+
+// MARK: Grid convenience initializers and mutators
+
+extension Grid {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(Grid.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        config: GridConfig?? = nil,
+        props: GridProps?? = nil
+    ) -> Grid {
+        return Grid(
+            config: config ?? self.config,
+            props: props ?? self.props
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - GridConfig
+struct GridConfig: Codable {
+    let items: [ComponentRef?]?
+
+    enum CodingKeys: String, CodingKey {
+        case items = "items"
+    }
+}
+
+// MARK: GridConfig convenience initializers and mutators
+
+extension GridConfig {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(GridConfig.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        items: [ComponentRef?]?? = nil
+    ) -> GridConfig {
+        return GridConfig(
+            items: items ?? self.items
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - ComponentRef
+struct ComponentRef: Codable {
+    let id: String?
+
+    enum CodingKeys: String, CodingKey {
+        case id = "id"
+    }
+}
+
+// MARK: ComponentRef convenience initializers and mutators
+
+extension ComponentRef {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(ComponentRef.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        id: String?? = nil
+    ) -> ComponentRef {
+        return ComponentRef(
+            id: id ?? self.id
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - GridProps
+struct GridProps: Codable {
+    let items: [ComponentRef?]?
+
+    enum CodingKeys: String, CodingKey {
+        case items = "items"
+    }
+}
+
+// MARK: GridProps convenience initializers and mutators
+
+extension GridProps {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(GridProps.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        items: [ComponentRef?]?? = nil
+    ) -> GridProps {
+        return GridProps(
+            items: items ?? self.items
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - Error
+struct Error: Codable {
+    let message: String
+
+    enum CodingKeys: String, CodingKey {
+        case message = "message"
+    }
+}
+
+// MARK: Error convenience initializers and mutators
+
+extension Error {
+    init(data: Data) throws {
+        self = try newJSONDecoder().decode(Error.self, from: data)
+    }
+
+    init(_ json: String, using encoding: String.Encoding = .utf8) throws {
+        guard let data = json.data(using: encoding) else {
+            throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
+        }
+        try self.init(data: data)
+    }
+
+    init(fromURL url: URL) throws {
+        try self.init(data: try Data(contentsOf: url))
+    }
+
+    func with(
+        message: String? = nil
+    ) -> Error {
+        return Error(
+            message: message ?? self.message
+        )
+    }
+
+    func jsonData() throws -> Data {
+        return try newJSONEncoder().encode(self)
+    }
+
+    func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
+        return String(data: try self.jsonData(), encoding: encoding)
+    }
+}
+
+// MARK: - Helper functions for creating encoders and decoders
+
+func newJSONDecoder() -> JSONDecoder {
+    let decoder = JSONDecoder()
+    decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in
+        let container = try decoder.singleValueContainer()
+        let dateStr = try container.decode(String.self)
+
+        let formatter = DateFormatter()
+        formatter.calendar = Calendar(identifier: .iso8601)
+        formatter.locale = Locale(identifier: "en_US_POSIX")
+        formatter.timeZone = TimeZone(secondsFromGMT: 0)
+        formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
+        if let date = formatter.date(from: dateStr) {
+            return date
+        }
+        formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX"
+        if let date = formatter.date(from: dateStr) {
+            return date
+        }
+        throw DecodingError.typeMismatch(Date.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Could not decode date"))
+    })
+    return decoder
+}
+
+func newJSONEncoder() -> JSONEncoder {
+    let encoder = JSONEncoder()
+    let formatter = DateFormatter()
+    formatter.calendar = Calendar(identifier: .iso8601)
+    formatter.locale = Locale(identifier: "en_US_POSIX")
+    formatter.timeZone = TimeZone(secondsFromGMT: 0)
+    formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX"
+    encoder.dateEncodingStrategy = .formatted(formatter)
+    return encoder
+}
diff --git a/base/graphql-typescript/test/inputs/graphql/github7.graphql/default/TopLevel.ts b/head/graphql-typescript/test/inputs/graphql/github7.graphql/default/TopLevel.ts
index 7e4305c..2735a58 100644
--- a/base/graphql-typescript/test/inputs/graphql/github7.graphql/default/TopLevel.ts
+++ b/head/graphql-typescript/test/inputs/graphql/github7.graphql/default/TopLevel.ts
@@ -18,11 +18,11 @@ export interface Data {
 
 export interface User {
     login:               string;
-    starredRepositories: Connection;
-    repositories:        RepositoryConnection;
+    starredRepositories: StarredRepositoryConnection;
+    repositories:        UserRepositoryConnection;
 }
 
-export interface RepositoryConnection {
+export interface UserRepositoryConnection {
     edges: (RepositoryEdge | null)[] | null;
 }
 
@@ -32,13 +32,29 @@ export interface RepositoryEdge {
 
 export interface Repository {
     name:       string;
-    stargazers: Connection;
-    forks:      Connection;
-    watchers:   Connection;
-    issues:     Connection;
+    stargazers: StargazerConnection;
+    forks:      RepositoryRepositoryConnection;
+    watchers:   UserConnection;
+    issues:     IssueConnection;
 }
 
-export interface Connection {
+export interface RepositoryRepositoryConnection {
+    totalCount: number;
+}
+
+export interface IssueConnection {
+    totalCount: number;
+}
+
+export interface StargazerConnection {
+    totalCount: number;
+}
+
+export interface UserConnection {
+    totalCount: number;
+}
+
+export interface StarredRepositoryConnection {
     totalCount: number;
 }
 
@@ -221,10 +237,10 @@ const typeMap: any = {
     ], false),
     "User": o([
         { json: "login", js: "login", typ: "" },
-        { json: "starredRepositories", js: "starredRepositories", typ: r("Connection") },
-        { json: "repositories", js: "repositories", typ: r("RepositoryConnection") },
+        { json: "starredRepositories", js: "starredRepositories", typ: r("StarredRepositoryConnection") },
+        { json: "repositories", js: "repositories", typ: r("UserRepositoryConnection") },
     ], false),
-    "RepositoryConnection": o([
+    "UserRepositoryConnection": o([
         { json: "edges", js: "edges", typ: u(a(u(r("RepositoryEdge"), null)), null) },
     ], false),
     "RepositoryEdge": o([
@@ -232,12 +248,24 @@ const typeMap: any = {
     ], false),
     "Repository": o([
         { json: "name", js: "name", typ: "" },
-        { json: "stargazers", js: "stargazers", typ: r("Connection") },
-        { json: "forks", js: "forks", typ: r("Connection") },
-        { json: "watchers", js: "watchers", typ: r("Connection") },
-        { json: "issues", js: "issues", typ: r("Connection") },
+        { json: "stargazers", js: "stargazers", typ: r("StargazerConnection") },
+        { json: "forks", js: "forks", typ: r("RepositoryRepositoryConnection") },
+        { json: "watchers", js: "watchers", typ: r("UserConnection") },
+        { json: "issues", js: "issues", typ: r("IssueConnection") },
+    ], false),
+    "RepositoryRepositoryConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "IssueConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "StargazerConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
+    ], false),
+    "UserConnection": o([
+        { json: "totalCount", js: "totalCount", typ: 0 },
     ], false),
-    "Connection": o([
+    "StarredRepositoryConnection": o([
         { json: "totalCount", js: "totalCount", typ: 0 },
     ], false),
     "Error": o([
diff --git a/base/graphql-typescript/test/inputs/graphql/github9.graphql/default/TopLevel.ts b/head/graphql-typescript/test/inputs/graphql/github9.graphql/default/TopLevel.ts
index b211efc..a468697 100644
--- a/base/graphql-typescript/test/inputs/graphql/github9.graphql/default/TopLevel.ts
+++ b/head/graphql-typescript/test/inputs/graphql/github9.graphql/default/TopLevel.ts
@@ -30,7 +30,11 @@ export type ReactionContent = "THUMBS_UP" | "THUMBS_DOWN" | "LAUGH" | "HOORAY" |
 
 export interface Reactable {
     viewerCanReact: boolean;
-    reactionGroups: Reaction[] | null;
+    reactionGroups: ReactionGroup[] | null;
+}
+
+export interface ReactionGroup {
+    content: ReactionContent;
 }
 
 export interface Error {
@@ -220,7 +224,10 @@ const typeMap: any = {
     ], false),
     "Reactable": o([
         { json: "viewerCanReact", js: "viewerCanReact", typ: true },
-        { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("Reaction")), null) },
+        { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("ReactionGroup")), null) },
+    ], false),
+    "ReactionGroup": o([
+        { json: "content", js: "content", typ: r("ReactionContent") },
     ], false),
     "Error": o([
         { json: "message", js: "message", typ: "" },
diff --git a/head/graphql-typescript/test/inputs/graphql/separate-types1.graphql/default/TopLevel.ts b/head/graphql-typescript/test/inputs/graphql/separate-types1.graphql/default/TopLevel.ts
new file mode 100644
index 0000000..15fdc63
--- /dev/null
+++ b/head/graphql-typescript/test/inputs/graphql/separate-types1.graphql/default/TopLevel.ts
@@ -0,0 +1,229 @@
+// To parse this data:
+//
+//   import { Convert, TopLevel } from "./TopLevel";
+//
+//   const topLevel = Convert.toTopLevel(json);
+//
+// These functions will throw an error if the JSON doesn't
+// match the expected interface, even if the JSON is valid.
+
+export interface TopLevel {
+    data:    Data | null;
+    errors?: Error[];
+}
+
+export interface Data {
+    grid: Grid | null;
+}
+
+export interface Grid {
+    config: GridConfig | null;
+    props:  GridProps | null;
+}
+
+export interface GridConfig {
+    items: (ComponentRef | null)[] | null;
+}
+
+export interface ComponentRef {
+    id: null | string;
+}
+
+export interface GridProps {
+    items: (ComponentRef | null)[] | null;
+}
+
+export interface Error {
+    message: string;
+}
+
+// Converts JSON strings to/from your types
+// and asserts the results of JSON.parse at runtime
+export class Convert {
+    public static toTopLevel(json: string): TopLevel {
+        return cast(JSON.parse(json), r("TopLevel"));
+    }
+
+    public static topLevelToJson(value: TopLevel): string {
+        return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
+    }
+}
+
+function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
+    const prettyTyp = prettyTypeName(typ);
+    const parentText = parent ? ` on ${parent}` : '';
+    const keyText = key ? ` for key "${key}"` : '';
+    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
+}
+
+function prettyTypeName(typ: any): string {
+    if (Array.isArray(typ)) {
+        if (typ.length === 2 && typ[0] === undefined) {
+            return `an optional ${prettyTypeName(typ[1])}`;
+        } else {
+            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
+        }
+    } else if (typeof typ === "object" && typ.literal !== undefined) {
+        return typ.literal;
+    } else {
+        return typeof typ;
+    }
+}
+
+function jsonToJSProps(typ: any): any {
+    if (typ.jsonToJS === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
+        typ.jsonToJS = map;
+    }
+    return typ.jsonToJS;
+}
+
+function jsToJSONProps(typ: any): any {
+    if (typ.jsToJSON === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
+        typ.jsToJSON = map;
+    }
+    return typ.jsToJSON;
+}
+
+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
+    function transformPrimitive(typ: string, val: any): any {
+        if (typeof typ === typeof val) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+
+    function transformUnion(typs: any[], val: any): any {
+        // val must validate against one typ in typs
+        const l = typs.length;
+        for (let i = 0; i < l; i++) {
+            const typ = typs[i];
+            try {
+                return transform(val, typ, getProps);
+            } catch (_) {}
+        }
+        return invalidValue(typs, val, key, parent);
+    }
+
+    function transformEnum(cases: string[], val: any): any {
+        if (cases.indexOf(val) !== -1) return val;
+        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
+    }
+
+    function transformArray(typ: any, val: any): any {
+        // val must be an array with no invalid elements
+        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
+        return val.map(el => transform(el, typ, getProps));
+    }
+
+    function transformDate(val: any): any {
+        if (val === null) {
+            return null;
+        }
+        const d = new Date(val);
+        if (isNaN(d.valueOf())) {
+            return invalidValue(l("Date"), val, key, parent);
+        }
+        return d;
+    }
+
+    function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
+        if (val === null || typeof val !== "object" || Array.isArray(val)) {
+            return invalidValue(l(ref || "object"), val, key, parent);
+        }
+        const result: any = {};
+        Object.getOwnPropertyNames(props).forEach(key => {
+            const prop = props[key];
+            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
+            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
+        });
+        Object.getOwnPropertyNames(val).forEach(key => {
+            if (!Object.prototype.hasOwnProperty.call(props, key)) {
+                result[key] = transform(val[key], additional, getProps, key, ref);
+            }
+        });
+        return result;
+    }
+
+    if (typ === "any") return val;
+    if (typ === null) {
+        if (val === null) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+    if (typ === false) return invalidValue(typ, val, key, parent);
+    let ref: any = undefined;
+    while (typeof typ === "object" && typ.ref !== undefined) {
+        ref = typ.ref;
+        typ = typeMap[typ.ref];
+    }
+    if (Array.isArray(typ)) return transformEnum(typ, val);
+    if (typeof typ === "object") {
+        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
+            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
+            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
+            : invalidValue(typ, val, key, parent);
+    }
+    // Numbers can be parsed by Date but shouldn't be.
+    if (typ === Date && typeof val !== "number") return transformDate(val);
+    return transformPrimitive(typ, val);
+}
+
+function cast<T>(val: any, typ: any): T {
+    return transform(val, typ, jsonToJSProps);
+}
+
+function uncast<T>(val: T, typ: any): any {
+    return transform(val, typ, jsToJSONProps);
+}
+
+function l(typ: any) {
+    return { literal: typ };
+}
+
+function a(typ: any) {
+    return { arrayItems: typ };
+}
+
+function u(...typs: any[]) {
+    return { unionMembers: typs };
+}
+
+function o(props: any[], additional: any) {
+    return { props, additional };
+}
+
+function m(additional: any) {
+    const props: any[] = [];
+    return { props, additional };
+}
+
+function r(name: string) {
+    return { ref: name };
+}
+
+const typeMap: any = {
+    "TopLevel": o([
+        { json: "data", js: "data", typ: u(r("Data"), null) },
+        { json: "errors", js: "errors", typ: u(undefined, a(r("Error"))) },
+    ], false),
+    "Data": o([
+        { json: "grid", js: "grid", typ: u(r("Grid"), null) },
+    ], false),
+    "Grid": o([
+        { json: "config", js: "config", typ: u(r("GridConfig"), null) },
+        { json: "props", js: "props", typ: u(r("GridProps"), null) },
+    ], false),
+    "GridConfig": o([
+        { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
+    ], false),
+    "ComponentRef": o([
+        { json: "id", js: "id", typ: u(null, "") },
+    ], false),
+    "GridProps": o([
+        { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
+    ], false),
+    "Error": o([
+        { json: "message", js: "message", typ: "" },
+    ], false),
+};
