From e0ad63617eb83283f37feb07f6c1975a9921be37 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Fri, 16 Feb 2018 11:03:32 +0100 Subject: [PATCH] sort type names when creating union type name to keep union type names more consistent previously this name would change when order of source data change --- packages/gatsby/src/schema/infer-graphql-type.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby/src/schema/infer-graphql-type.js b/packages/gatsby/src/schema/infer-graphql-type.js index fcdccdaa53b2b..bc9e296282787 100644 --- a/packages/gatsby/src/schema/infer-graphql-type.js +++ b/packages/gatsby/src/schema/infer-graphql-type.js @@ -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 =>