DEV Community

loading...

What localhost do I use? 3000/gql , 5000/gql

yobretyo profile image Bret ・1 min read

I have my CMS connected to my dB and creating data fine,
Apollo Graphql is showing the data fine through the editor,
BUT..... what should my server route look like??? Also, so I need cors???

Discussion (4)

pic
Editor guide
Collapse
aiosifelisl1 profile image
Andreas Iosifelis

Hey, take a look here apollographql.com/docs/apollo-serv...
Regarding the cors, you could proxy the requests from your devserver to the graphQL endpoint. But if you don't want to do this then you'll have to enable cors from the server.

Collapse
yobretyo profile image
Bret Author

Thank you, well, yes that part works... but I’m using this in a full stack project. I’m using MERN + Apollo GraphQL with my own data from MongoDB. How do I show my data? I have a getFish object that I want to display my info from
“iname, description, type, deadly”

But, it’s not working.

In the server, for the localhost since I’m using react.... what should it be on?

Collapse
nhidtran profile image
nhidtran • Edited

if you react app is running on port 3000
and your graphql server is running on port 5000, you'll want to make requests from your react app to fetch data
The port numbers are arbritary. You could make your react app run on 5000 and your server something like 9999. The number itself really doesn't matter, but think of it like addresses. One thing is running per address (like a house!). If you're at house 3000, you might call house 5000 for something

you can verify your server is returning the right data by postman or curl your request

you can also post your repo if you want some help hooking it all up! or if I'm not answering the question you trying to solve

Thread Thread
yobretyo profile image
Bret Author

Ok 👍 I added the cors, but it’s still not showing. I think it might be my actual query in the component. BUT, what is Schema.JS? Do I need that, OR, is that the gql folder on my client side??