Skip to content

Commit

Permalink
feat(gql): sort type fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Feb 1, 2024
1 parent 75a27fa commit 5eb5692
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/graphql/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,19 @@ export async function getGraphQLResourceSchema(ctx: Context, graphqlSchema: Reso
tags.push('root')
}

// Sort fields
const sortedFields = Object.values(fields).sort((a, b) => a.name.localeCompare(b.name))
const sortedFieldsMap: Record<string, ResourceSchemaField> = {}
for (const field of sortedFields) {
sortedFieldsMap[field.name] = field
}

const resType = {
name: gqlType.name,
tags,
description: gqlType.description ?? undefined,
array: !isRootType,
fields,
fields: sortedFieldsMap,
nonNull: false,
isDeprecated: false,
inline: inline && !isRootType,
Expand Down

0 comments on commit 5eb5692

Please sign in to comment.