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

previously this name would change when order of source data change
  • Loading branch information
pieh committed Feb 16, 2018
1 parent 784fa0c commit e0ad636
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 e0ad636

Please sign in to comment.