how to set up and run a GraphQL service to query Worldwide country.
- IDE: With a terminal (e.g., VS Code, IntelliJ)
- Docker: Installed and running
- Git: For cloning the repository
- cURL: For testing the service
-
Clone the Repository
Run the following command to clone the GraphQL service code:git clone https://github.com/Al-khawaja/Graphql.git
-
Build the Docker Image
Build the Docker application and tag it e.ggraphqlservice:docker build . -t graphqlservice -
Run the Application
Start the service on port 8080:docker run -dp 8080:4000 graphqlservice
A hex code will confirm the application has started.
-
Verify the Service
Check if the service is running:curl localhost:8080
If the output matches the expected format which is: "Copy the URL from the address-bar, to paste in Postman to use GraphQL", the service is up.
-
Verify the Service
Check if the service is running:curl localhost:8080
If the output matches the expected format which is: "Copy the URL from the address-bar, to paste in Postman to use GraphQL", the service is up.
curl -X POST <URL> -H "Content-Type: application/json" -d '{"query": "{ cities(country: \"Jordan\") { city Latitude Longitude country iso3 population } }"}'
- Ensure Docker is running before executing the commands.
- The service will be available at
localhost:8080or the provided URL.