relay: [relay-compiler] After upgrade to 1.5.0, it throws ERROR: Type "Address" already exists in the schema. It cannot also be defined in this type definition.

In our schema.graphql, we define a type Address for common address

type Address {
  city: String
  latitude: Float
  longitude: Float
  state: String
  staticMap: Image
  street: String
  zip: String
}

It works when we are using 1.4.1 without issues. But today when we upgrade to 1.5.0 (along with relay-runtime/react-relay) we no longer able to compile the static queries.

react-compiler keeps throwing ERROR: Type “Address” already exists in the schema. It cannot also be defined in this type definition.

After we downgrade to 1.4.1, the compiler works again.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 28 (16 by maintainers)

Commits related to this issue

Most upvoted comments

@steida After I move the schema.graphql out of src directory as well as changing the command. It seems working.

relay-compiler --src ./src --schema schema.graphql

1.4.1 accept the schema.graphql in the src folder. I guess the error is somehow related to “client-only schema extensions” feature. Does it scan the src folder for .graphql files and add additional type to schema definition? The main schema should be excluded from scanning in my opinion.

@jstejada I think we should fix this DX by excluding the --schema path from the found .graphql documents or do you foresee problems with that?

1.4.1 accept the schema.graphql in the src folder. I guess the error is somehow related to “client-only schema extensions” feature. Does it scan the src folder for .graphql files and add additional type to schema definition? The main schema should be excluded from scanning in my opinion.

@nightspirit I think this is correct! See #2264. I’m going to update the release note to indicate that this change can break the compiler and see if we can have a better error message for this.

Thanks! And sorry for the trouble!

@renatonmendes Yes, the problem is when your schema file resides inside the source root you specify with —src

I am seeing the same issue with a different type definition, also only have one defined.

@sibelius Yes, there is only one type Address in the schema.graphql file.