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

Error while using Graphql #6301

Closed
akashgreninja opened this issue Oct 4, 2023 · 4 comments · Fixed by #9246
Closed

Error while using Graphql #6301

akashgreninja opened this issue Oct 4, 2023 · 4 comments · Fixed by #9246
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause

Comments

@akashgreninja
Copy link

What version of Bun is running?

1.0.4+745b6b94ee56cad24d475799690cc9a89957d15b

What platform is your computer?

Ubuntu 22.04.3 LTS

What steps can reproduce the bug?

Creating a basic code to run a Graphql file

const { ApolloServer, gql } = require('apollo-server');

const typeDefs = gql`
  type Query {
    firstName: String
    middleName: String
    lastName: String
  }
`;

const resolvers = {
  Query: {
    firstName: () => "YourFirstName",
    middleName: () => "YourMiddleName",
    lastName: () => "YourLastName"
  }
};

const server = new ApolloServer({ typeDefs, resolvers });

server.listen().then(({ url }) => {
  console.log(`Server ready at ${url}`);
});

What is the expected behavior?

On testing in the graphql playground we must get a valid response ie

{
  "data": {
    "firstName": "YourFirstName",
    "middleName": "YourMiddleName",
    "lastName": "YourLastName"
  }
}

What do you see instead?

The error that comes in that playground is

 {
  "error": "Failed to fetch schema. Please check your connection"
}

and on the console

Error: Failed to construct 'Request': Invalid URL "/"
    at Request (native)
    at convertNodeHttpToRequest (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-core/dist/nodeHttpToRequest.js:16:8)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-express/dist/ApolloServer.js:81:58)
    at handle (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/layer.js:94:21)
    at trim_prefix (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:327:41)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:288:13)
    at process_params (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:349:6)
    at next (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:280:10)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/body-parser/lib/read.js:137:3)
    at runInAsyncScope (node:async_hooks:144:18)
    at invokeCallback (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:237:31)
    at done (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:229:13)
    at onEnd (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:286:23)
    at emit (native)
    at endReadableNT (node:stream:2387:27)
    at processTicksAndRejections (:55:39)
Error: Failed to construct 'Request': Invalid URL "/"
    at Request (native)
    at convertNodeHttpToRequest (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-core/dist/nodeHttpToRequest.js:16:8)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-express/dist/ApolloServer.js:81:58)
    at handle (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/layer.js:94:21)
    at trim_prefix (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:327:41)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:288:13)
    at process_params (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:349:6)
    at next (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:280:10)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/body-parser/lib/read.js:137:3)
    at runInAsyncScope (node:async_hooks:144:18)
    at invokeCallback (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:237:31)
    at done (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:229:13)
    at onEnd (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:286:23)
    at emit (native)
    at endReadableNT (node:stream:2387:27)
    at processTicksAndRejections (:55:39)
Error: Failed to construct 'Request': Invalid URL "/"
    at Request (native)
    at convertNodeHttpToRequest (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-core/dist/nodeHttpToRequest.js:16:8)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-express/dist/ApolloServer.js:81:58)
    at handle (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/layer.js:94:21)
    at trim_prefix (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:327:41)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:288:13)
    at process_params (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:349:6)
    at next (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:280:10)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/body-parser/lib/read.js:137:3)
    at runInAsyncScope (node:async_hooks:144:18)
    at invokeCallback (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:237:31)
    at done (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:229:13)
    at onEnd (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:286:23)
    at emit (native)
    at endReadableNT (node:stream:2387:27)
    at processTicksAndRejections (:55:39)
Error: Failed to construct 'Request': Invalid URL "/"
    at Request (native)
    at convertNodeHttpToRequest (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-core/dist/nodeHttpToRequest.js:16:8)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-express/dist/ApolloServer.js:81:58)
    at handle (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/layer.js:94:21)
    at trim_prefix (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:327:41)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:288:13)
    at process_params (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:349:6)
    at next (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:280:10)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/body-parser/lib/read.js:137:3)
    at runInAsyncScope (node:async_hooks:144:18)
    at invokeCallback (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:237:31)
    at done (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:229:13)
    at onEnd (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:286:23)
    at emit (native)
    at endReadableNT (node:stream:2387:27)
    at processTicksAndRejections (:55:39)
Error: Failed to construct 'Request': Invalid URL "/"
    at Request (native)
    at convertNodeHttpToRequest (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-core/dist/nodeHttpToRequest.js:16:8)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/apollo-server-express/dist/ApolloServer.js:81:58)
    at handle (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/layer.js:94:21)
    at trim_prefix (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:327:41)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:288:13)
    at process_params (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:349:6)
    at next (/home/akash/Desktop/graphql benchmark test/node_modules/express/lib/router/index.js:280:10)
    at <anonymous> (/home/akash/Desktop/graphql benchmark test/node_modules/body-parser/lib/read.js:137:3)
    at runInAsyncScope (node:async_hooks:144:18)
    at invokeCallback (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:237:31)
    at done (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:229:13)
    at onEnd (/home/akash/Desktop/graphql benchmark test/node_modules/raw-body/index.js:286:23)
    at emit (native)
    at endReadableNT (node:stream:2387:27)
    at processTicksAndRejections (:55:39)

Additional information

Screenshot from 2023-10-04 23-02-33

@akashgreninja akashgreninja added the bug Something isn't working label Oct 4, 2023
@miguelemosreverte
Copy link

same here

@Electroid
Copy link
Contributor

That error is coming from Node.js, what command are you using to run this code?

@Electroid Electroid added the needs investigate Needs to be investigated to find the root cause label Oct 30, 2023
@akashgreninja
Copy link
Author

bun run index.js

@ali-gol
Copy link

ali-gol commented Nov 6, 2023

@Electroid this issue is actually related with ApolloServer. From my understanding; they have a single strong dependency to node. apollographql/apollo-server#7733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants