@@ -76,7 +76,7 @@ class PostGraphiQL extends React.Component {
76
76
// TODO: Send the introspection query results in the server sent event?
77
77
async updateSchema ( ) {
78
78
// Don’t allow users to see a schema while we update.
79
- this . setState ( { schema : null } )
79
+ this . setState ( { schema : undefined } )
80
80
81
81
// Fetch the schema using our introspection query and report once that has
82
82
// finished.
@@ -117,13 +117,21 @@ class PostGraphiQL extends React.Component {
117
117
// Ok, so if you look at GraphiQL source code, the `navStack` is made up of
118
118
// objects that are either types or fields. Let’s use that to search in
119
119
// our new schema for matching (updated) types and fields.
120
- const nextNavStack = navStack . map ( ( typeOrField , i ) => {
120
+ const nextNavStack = navStack . map ( ( navStackItem , i ) => {
121
121
// If we are not ok, abort!
122
122
if ( ! allOk )
123
123
return null
124
124
125
+ // Get the definition from the nav stack item.
126
+ const typeOrField = navStackItem . def
127
+
128
+ // If there is no type or field then this is likely the root schema view,
129
+ // or a search. If this is the case then just return that nav stack item!
130
+ if ( ! typeOrField ) {
131
+ return navStackItem
132
+ }
125
133
// If this is a type, let’s do some shenanigans...
126
- if ( isType ( typeOrField ) ) {
134
+ else if ( isType ( typeOrField ) ) {
127
135
// Let’s see if we can get a type with the same name.
128
136
const nextType = nextSchema . getType ( typeOrField . name )
129
137
@@ -136,7 +144,7 @@ class PostGraphiQL extends React.Component {
136
144
137
145
// If there is a type with the same name, let’s return it! This is the
138
146
// new type with all our new information.
139
- return nextType
147
+ return { ... navStackItem , def : nextType }
140
148
}
141
149
// If you thought this function was already pretty bad, it’s about to get
142
150
// worse. We want to update the information for an object field.
@@ -168,7 +176,7 @@ class PostGraphiQL extends React.Component {
168
176
}
169
177
170
178
// Otherwise we hope very much that it is correct.
171
- return nextField
179
+ return { ... navStackItem , def : nextField }
172
180
}
173
181
} )
174
182
0 commit comments