Anyone tried to setup a graphqlapi with apollo-ser...
# help
s
Anyone tried to setup a graphqlapi with apollo-server-lambda recently? Currently getting stuck due to graphql version mismatch errors. Seems some dependencies of sst have defined peerDependencies for
graphql: ^14.0.0 || ^15.0.0
, but not version 16+. From what I can tell, these are all updated on their respective github repos, but not included when installing the serverless stack dependencies.
Copy code
├─┬ @serverless-stack/cli@1.1.2
│ └─┬ @graphql-codegen/cli@2.6.2
│   ├─┬ @graphql-codegen/core@2.5.1
│   │ └── graphql@16.5.0 deduped invalid: "^14.0.0 || ^15.0.0" from node_modules/@serverless-stack/resources/node_modules/@graphql-tools/merge
│   ├─┬ @graphql-codegen/plugin-helpers@2.4.2
│   │ └── graphql@16.5.0 deduped invalid: "^14.0.0 || ^15.0.0" from node_modules/@serverless-stack/resources/node_modules/@graphql-tools/merge
│   ├─┬ @graphql-tools/apollo-engine-loader@7.2.18
│   │ └── graphql@16.5.0 deduped invalid: "^14.0.0 || ^15.0.0" from node_modules/@serverless-stack/resources/node_modules/@graphql-tools/merge
Error I'm getting is:
Copy code
ERROR Runtime.UnhandledPromiseRejection: Error: Cannot use GraphQLSchema "{ __validationErrors: undefined, description: undefined, extensions: {}, astNode: { kind: "SchemaDefinition", operationTypes: [Array] }, extensionASTNodes: [], _queryType: Query, _mutationType: undefined, _subscriptionType: undefined, _directives: [@include, @skip, @deprecated, @specifiedBy], _typeMap: { Query: Query, String: String, 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.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

<https://yarnpkg.com/en/docs/selective-version-resolutions>

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
I've tried installing graphql 15.8.0 and using resolutions in my package.json files, none seem to solve the issue. Any ideas?
t
can you try
sst update snapshot
delete node modules and install again
and see
I updated everything recently but we haven't released it yet
btw we're about to share this today which is our recommended gql setup going forward: https://github.com/serverless-stack/ideal-stack-preview
it's what I referenced in my talk:

https://youtu.be/6FzLjpMYcu8?t=5182

s
alright, cool - I'll give it a go
So the
sst update snapshot
solved the issue where peerDependencies didn't have the latest version of graphql, but the graphql mismatch was still present. I uninstalled
apollo-server-lambda
and went for
@serverless-stack/node/graphql
which worked. Might be an idea to test with apollo-server-lambda or update your example (linked above) to reflect any changes needed so others don't encounter same issue with apollo Anyway, thanks for help/links