Skip to content

Commit

Permalink
sort type names when creating union type name to keep union type name…
Browse files Browse the repository at this point in the history
…s more consistent (#4074)

previously this name would change when order of source data change
  • Loading branch information
pieh authored and KyleAMathews committed Feb 16, 2018
1 parent 2ce6c5c commit 006df2d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/gatsby/src/schema/infer-graphql-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,10 @@ function inferFromFieldName(value, selector, types): GraphQLFieldConfig<*, *> {
// If there's more than one type, we'll create a union type.
if (fields.length > 1) {
type = new GraphQLUnionType({
name: `Union_${key}_${fields.map(f => f.name).join(`__`)}`,
name: `Union_${key}_${fields.map(f => f.name).sort().join(`__`)}`,
description: `Union interface for the field "${key}" for types [${fields
.map(f => f.name)
.sort()
.join(`, `)}]`,
types: fields.map(f => f.nodeObjectType),
resolveType: data =>
Expand Down

0 comments on commit 006df2d

Please sign in to comment.