Issue with GraphQL after updating to 6.1.0

Recently I upgraded to Redwood 6.1.0. I believe I followed all the instructions and everything seemed to go well at first. When I ran ‘yarn rw dev’ and got the following error in the console.

api | Importing Server Functions... 
api | 14:18:58 🌲 Subscriptions are disabled.
api | /auth 2 ms
api | Took 2324 ms
api | API listening on http://localhost:8911/
api | GraphQL endpoint at /graphql
api | 14:18:58 🌲 Server listening at http://[::]:8911
api | 14:18:58 🐛 GraphiQL and Introspection Config 
api | 🗒 Custom
api | {
api |   "defaultAllowedOperations": [
api |     "query",
api |     "mutation"
api |   ],
api |   "defaultError": "Something went wrong.",
api |   "disableIntrospection": false,
api |   "disableGraphQL": false,
api |   "graphiql": {
api |     "title": "Redwood GraphQL Playground",
api |     "headers": "{\"x-auth-comment\": \"See documentation: on how to auto generate auth headers\"}",
api |     "defaultQuery": "query Redwood {\n    redwood {\n    version\n    }\n  }",
api |     "headerEditorEnabled": true
api |   },
api |   "graphiQLEndpoint": "/graphql"
api | }
api | Error: Cannot use GraphQLSchema "{ __validationErrors: undefined, description: undefined, extensions: {}, astNode: { kind: "SchemaDefinition", description: undefined, directives: [], operationTypes: [Array], loc: [Object] }, extensionASTNodes: [], _queryType: Query, _mutationType: Mutation, _subscriptionType: undefined, _directives: [@requireAuth, @skipAuth, @include, @skip, @deprecated, @specifiedBy], _typeMap: { BigInt: BigInt, Date: Date, Time: Time, DateTime: DateTime, JSON: JSON, JSONObject: JSONObject, Redwood: Redwood, String: String, Query: Query, Int: Int, UserRole: UserRole, CreateUserRoleInput: CreateUserRoleInput, UpdateUserRoleInput: UpdateUserRoleInput, Mutation: Mutation, User: User, CreateUserInput: CreateUserInput, UpdateUserInput: UpdateUserInput, Boolean: Boolean, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _subTypeMap: {}, _implementationsMap: {} }" from another module or realm.
api |
api | Ensure that there is only one instance of "graphql" in the node_modules
api | directory. If different versions of "graphql" are the dependencies of other
api | relied on modules, use "resolutions" to ensure only one version is installed.
api |
api |
api |
api | Duplicate "graphql" modules cannot be used at the same time since different
api | versions may have different capabilities and behavior. The data from one
api | version used in the function from another could produce confusing and
api | spurious results.
api |     at instanceOf (C:\Kosmos\app\node_modules\graphql\jsutils\instanceOf.js:43:19)
api |     at isSchema (C:\Kosmos\app\node_modules\graphql\type\schema.js:32:37)
api |     at useSchema (C:\Kosmos\app\node_modules\graphql-yoga\cjs\plugins\use-schema.js:9:32)
api |     at new YogaServer (C:\Kosmos\app\node_modules\graphql-yoga\cjs\server.js:159:64)
api |     at createYoga (C:\Kosmos\app\node_modules\graphql-yoga\cjs\server.js:329:20)
api |     at createGraphQLYoga (C:\Kosmos\app\node_modules\@redwoodjs\graphql-server\dist\createGraphQLYoga.js:173:46)
api |     at createGraphQLHandler (C:\Kosmos\app\node_modules\@redwoodjs\graphql-server\dist\functions\graphql.js:51:48)
api |     at Object.<anonymous> (C:\Kosmos\app\api\src\functions\graphql.js:12:24)
api |     at Module._compile (node:internal/modules/cjs/loader:1105:14)
api |     at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
api |
api | Node.js v18.2.0

According to the error message there are duplicate graphql modules. In my nodes_modules I have the following:


I’ve tried several things to resolve this issue:

  1. Deleted the nodes_modules directory and ran yarn install
  2. Reverted back to the version before I attempted the upgrade, performed the upgrade steps again
  3. Manually deleted the graphql directory

I’m at a loss now. Any suggestions will be greatly appreciated.

Sounds like there are two versions of graphql.

Can you “yarn why” to see the versions used?

Maybe delete mode modules and yarn install again?

Did you pin or set the graphql pavkagw anywhere else in package.json?

Thanks for quick the response.

The “yarn why” was a feature I didn’t know existed. I used it, and it gave me some output, but I really didn’t understand how to interpret what it was telling me based on the issue I was having.

I did try deleting all the node_modules and running yarn install. That was actually the first thing I did before I posted the the original question.

I’m not sure what " pin or set the graphql pavkagw" means, so I don’t think I did that anywhere.

But the good news, is I have the app working again with 6.1.0. (Almost working) Here is what I did:

  1. I reverted back to my last working version which was RW 5.3.1
  2. Followed all the upgrade instructions except updating Prisma to v5 and Storybook to v7. I had previously followed those steps also.

One thought I had that could have caused the problem is when I tried to update to Prisma V5. In their instructions, that the Redwood guide links to, they give the commands for doing the upgrading using npm, yarn & pnpm. When I tried the yarn method “yarn upgrade prisma@5 @prisma/client@5” it gave some error that no such command exists. I also tried “yarn rw upgrade prisma@5 @prisma/client@5”. It didn’t work either. I then tried the npm method, from the project root and it updated. I know there are separate package.json files for the web and api. Grasping at straws, but maybe that was the issue?

So the app is running, but Storybook is not. The upgrade guide mentioned there is a minor upgrade coming for Storybook so maybe that will fix that problem? I’m holding off on the Storybook upgrade for now, but it is something that we use and I will need to address in the near future.

Again, thanks for the response. Our team is really enjoying the Redwood framework.

1 Like