ardatan/graphql-import

v0.6.0 breaks import functionality (working in v0.5.2)

Opened this issue ยท 6 comments

I upgraded the nxplorerJS project to v0.6.0 and got the following error

Syntax Error: Unexpected <EOF>
    
    GraphQL request (2:1)
    1: 
    2: 
       ^
      22 | // Create GraphQL Schema with all the pieces in place 
      23 | export const setupSchema = (): GraphQLSchema => {
    > 24 |   const schema = makeExecutableSchema({
      25 |     typeDefs,
      26 |     resolvers: resolvers,
      27 |     schemaDirectives: {

Here is the travis build reference https://travis-ci.org/ERS-HCL/nxplorerjs-microservice-starter/jobs/382177481

This appears to be related to #45 but when I added a dummy type the wildcard imports do not get imported properly

Code snippet

const typeDefs = importSchema('server/graphql/schema/main.graphql');
...
export const setupSchema = (): GraphQLSchema => {
		  const schema = makeExecutableSchema({
			typeDefs,
			resolvers: resolvers,
			schemaDirectives: {
			  date: FormattableDateDirective,
			  auth: AuthDirective
			}
		});

main.graphql

# import * from "./starwars.graphql"
# import * from "./example.graphql"
# import * from "./user.graphql"
# import * from "./movie.graphql"
# import * from "./blog.graphql"
# import * from "./schema.graphql"

I can confirm that breaks import * from file after upgrade from 0.52 to 0.6.0

# import Query.*, Mutation.*, * from "./starwars.graphql" works for me after upgrading from 0.4.5 to 0.6.0

alvis commented

๐Ÿค” import * from file works fine to me with 0.6.

@tsukhu & @czystyl: could you prepare a minimal example?

@alvis Given that different people are having different results, this may be some specific scenario which is not working. I will try to do to create a separate sample. But if you want to look at it immediately you can check

https://github.com/ERS-HCL/nxplorerjs-microservice-starter. Once you upgrade to graphql-imports to 0.6.0 and the imports stop working there after. I had upgraded it to 0.6.0 from 0.5.2 but the build broke, hence I reverted it back.

OK .. I have debugged the issue and was able to fix the build (using 0.6.0) with the following changes

With v0.6.0 the standard schema types of Query , Mutation and Subscription MUST be provided with the root field types of Query.* , Mutation.* and Subscription.* otherwise we get a runtime error of 'EOF'

The earlier version was allowing using the wild cards only for these types as well. I guess this is also fine , but we need to have a note in the README to mention that for people upgrading from earlier versions

image

tsukhu/nxplorerjs-microservice-starter#124
With this change the travis build issue is now resolved for me. https://travis-ci.org/ERS-HCL/nxplorerjs-microservice-starter/builds/393489075

alvis commented

So it is related to #176, which was merged since 0.5.3.

To be fair, the change is mentioned as tiny words in https://github.com/prismagraphql/graphql-import/releases#0.5.3, but @tsukhu is right that it's a breaking change and it should be properly documented.

ping @timsuchanek & @schickling