Commit 9366cb2 1 parent 951ec25 commit 9366cb2 Copy full SHA for 9366cb2
File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import { Kind } from 'gatsby/graphql';
5
5
import type { TypegenReporter } from './internal/reporter' ;
6
6
import { validateConfig } from './internal/config' ;
7
7
import { typegenMachine } from './internal/machine' ;
8
+ import { sortDefinitions } from './internal/utils' ;
9
+
8
10
import { makeEmitSchemaService } from './services/emitSchema' ;
9
11
import { makeEmitPluginDocumentService } from './services/emitPluginDocument' ;
10
12
import { makeAutofixService } from './services/autofix' ;
@@ -150,6 +152,7 @@ export const onPreBootstrap: GatsbyNode['onPreBootstrap'] = ({
150
152
codegen : context => codegen ( {
151
153
schema : context . schema ! ,
152
154
documents : [ ...context . trackedDefinitions ?. values ( ) || [ ] ]
155
+ . sort ( sortDefinitions )
153
156
. map ( definitionMeta => ( {
154
157
document : {
155
158
kind : Kind . DOCUMENT ,
Original file line number Diff line number Diff line change @@ -191,3 +191,15 @@ export function filterPluginSchema(schema: GraphQLSchema): GraphQLSchema {
191
191
export function stabilizeSchema ( schema : GraphQLSchema ) : GraphQLSchema {
192
192
return lexicographicSortSchema ( filterDevOnlySchema ( schema ) ) ;
193
193
}
194
+
195
+ export function sortDefinitions ( a : IDefinitionMeta , b : IDefinitionMeta ) : number {
196
+ const aKey = a . name ;
197
+ const bKey = b . name ;
198
+ if ( aKey < bKey ) {
199
+ return - 1 ;
200
+ }
201
+ if ( aKey > bKey ) {
202
+ return 1 ;
203
+ }
204
+ return 0 ;
205
+ }
You can’t perform that action at this time.
0 commit comments