Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apollo server 3 does not work with serverless offline #5738

Closed
Krishantha opened this issue Sep 22, 2021 · 2 comments
Closed

Apollo server 3 does not work with serverless offline #5738

Krishantha opened this issue Sep 22, 2021 · 2 comments

Comments

@Krishantha
Copy link

Apollo server 3 with AWS lambda (apollo-server-lambda) does not compatible with serverless offline plugin.

const server = new ApolloServer({
  plugins: [ApolloServerPluginLandingPageGraphQLPlayground()],
  typeDefs: typeDefs,
  resolvers: resolvers,
  introspection: true,
});

its starts fine.

Serverless: Running "serverless" installed locally (in service node_modules)
offline: Starting Offline: dev/ap-southeast-1.
offline: Offline [http for lambda] listening on http://localhost:3002
offline: Function names exposed for local invocation by aws-sdk:
           * employee: aws-apollo-demo-dev-employee

   ┌────────────────────────────────────────────────────────────────────────────┐
   │                                                                            │
   │   POST | http://localhost:3000/dev                                         │
   │   POST | http://localhost:3000/2015-03-31/functions/employee/invocations   │
   │   GET  | http://localhost:3000/dev                                         │
   │   POST | http://localhost:3000/2015-03-31/functions/employee/invocations   │
   │                                                                            │
   └────────────────────────────────────────────────────────────────────────────┘

offline: [HTTP] server ready: http://localhost:3000 🚀
offline: 
offline: Enter "rp" to replay the last request

but when query it gives an error.

current

Cannot POST null

expected

should return result and / should show playground as it does on apollo-server-lambda 2.x.x

how ever if I downgrade to apollo-server-lambda 2.x.x everything works fine with serverless offline.

also this works when deployed to aws.

how we can get this works with sls offline.

@glasser
Copy link
Member

glasser commented Sep 28, 2021

Hi! I know we document how to use serverless but I'm not familiar with the offline plugin. In order to reproduce the issue, I'd like to have to apply any creativity. Are you able to provide a full reproduction (eg, starting with git clone) that includes all of the files relevant (including however you enable offline) so we can see it ourselves in exactly the same way you see it? Happy to reopen if a full reproduction is included.

@glasser glasser closed this as completed Sep 28, 2021
@UncleGrim
Copy link

UncleGrim commented Apr 4, 2022

Made an account for anyone else that stumbles upon this.

The problem with serverless-offline and Apollo3 is the default url property has changed.

See this post

To validate try issuing requests against the /graphql URI, this worked for me.

Edit: Upon further inspection it looks like any route that isn't the root /dev/ works. Curious...

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants