在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):GraphQL-Portal/graphql-portal开源软件地址(OpenSource Url):https://github.com/GraphQL-Portal/graphql-portal开源编程语言(OpenSource Language):TypeScript 96.3%开源软件介绍(OpenSource Introduction):GraphQL Portal GatewayConverge all your data sources into One Graph with a configurable, distributed and open source GraphQL Gateway. MotivationThe GraphQL Community and Ecosystem are growing rapidly, and the goal of GraphQL Portal is to bring an API Gateway that is native to GraphQL. It is designed to be a simple and universal GraphQL Gateway for those who must mix legacy services with new ones exposing GraphQL APIs, but also for those who already have GraphQL APIs and want to have a light gateway that will bring more control and visibility to their APIs. It is open source by choice, relies on existing open source tools by design, is extendable, scalable and configurable. It can either be installed on-premises, or be used as a SaaS Gateway (coming soon). Key facts and features:
Table of contentsHow it worksGraphQL Portal consists of two major components:
We plan on adding a GraphQL Registry in the future. In a full-power mode, GraphQL Portal will require two more components: Redis and MongoDB. Once installed and configured, the Gateway allows you to:
Quick StartTL;DR? The quickest way to launch GraphQL Portal (with Gateway and Dashboard) locally, is to use our Docker Compose file: git clone [email protected]:GraphQL-Portal/graphql-portal-docker.git
cd graphql-portal-docker
docker-compose -f docker-compose.yml up This will launch the Gateway, Dashboard, as well as Redis and MongoDB. Where to go from here? We would suggest creating some APIs and playing with the data connectors. Read more about that here. InstallationPrerequisitesUnless installed via docker compose, you will need:
Docker ComposeCheck out our dedicated repository with docker compose files and examples of the configuration: git clone [email protected]:GraphQL-Portal/graphql-portal-docker.git
cd graphql-portal-docker
docker-compose -f docker-compose.yml up Standalone Docker containersInstall and launch the Gateway: docker pull gqlportal/gateway:latest Now that you have Docker image locally, you will need to prepare a basic configuration file. You may download a sample config: curl -s -o ./gateway.yaml https://raw.githubusercontent.com/graphql-portal/graphql-portal-docker/main/basic.gateway.yaml Once that is done, you can now launch the Gateway in a standalone mode (you may have to specify a Redis connection string relevant to your local environment): docker run --name graphql-gateway \
-p 3000:3000 \
-e REDIS="redis://localhost:6379" \
-v $(pwd)/gateway.yaml:/opt/graphql-portal/config/gateway.yaml \
gqlportal/gateway:latest Install and launch Dashboard: docker pull gqlportal/dashboard:latest
# Modify the connection strings depending on your environment
docker run --name graphql-dashboard \
-e REDIS_CONNECTION_STRING="redis://localhost:6379" \
-e MONGODB_CONNECTION_STRING="mongodb://localhost:27017" \
-e DASHBOARD_PORT=3030 \
-e NODE_ENV=production \
-p 3030:3030 \
gqlportal/dashboard:latest You now should be able to open the configuration dashboard by going to http://localhost:3030 in your browser. Standalone Gateway with Yarn/NPMThe Gateway can also be installed either via npm/yarn, or by pulling this repository and then building the source codes. The package # create directories for configuration
mkdir -p /opt/graphql-portal/config && cd /opt/graphql-portal
# download a basic configuration file
curl -s -o ./config/gateway.yaml https://raw.githubusercontent.com/graphql-portal/graphql-portal-docker/main/basic.gateway.yaml Now that the configuration is in place, we can install and launch the gateway: # install the gateway and go to the directory with configuration
yarn global add @graphql-portal/gateway
# @graphql-portal/gateway package provides a CLI command graphql-portal
# we will also need a Redis connection string in order to launch the gateway
env REDIS="redis://localhost:6379" NODE_ENV=production graphql-portal You should now see the output of the server without any errors. Read more about the configuration of the gateway here. Standalone Dashboard without DockerAt the moment, GraphQL Portal Dashboard consists from the following components:
and requires the following dependencies:
It is not distributed via Yarn/NPM and can be installed locally by pulling and building the source code from the repository: mkdir /opt/graphql-portal-dashboard
git clone https://github.com/graphql-portal/graphql-portal-dashboard /opt/graphql-portal-dashboard
cd /opt/graphql-portal-dashboard
# the following two steps can take some time
yarn install --frozen-lockfile
yarn build We'll have to edit the configuration file before launching the server. To do that, open the configuration file for production environment: vim packages/backend/config/env/production.json {
"application": {
"env": "production",
"useSwaggerUi": false,
"port": "@@DASHBOARD_PORT",
"host": "@@HOST",
"graphQL": {
"playground": false,
"debug": false
},
"logLevel": "log",
"defaultAdmin": {
"email": "@@DEFAULT_ADMIN_EMAIL",
"password": "@@DEFAULT_ADMIN_PASSWORD"
},
"sendgrid": {
"senderEmail": "@@SENDGRID_SENDER_EMAIL",
"apiKey": "@@SENDGRID_API_KEY"
},
"mail": {
"driver": "@@MAIL_DRIVER",
"from": "@@MAIL_FROM",
"sendgrid": {
"apiKey": "@@SENDGRID_API_KEY"
},
"smtp": {
"host": "@@SMTP_HOST",
"port": "@@SMTP_PORT",
"auth": {
"user": "@@SMTP_USER",
"pass": "@@SMTP_PASS",
},
"secure": "@@SMTP_SECURE",
},
},
"metrics": {
"enabled": "@@METRICS_ENABLED",
"chunk": "@@METRICS_CHUNK",
"delay": "@@METRICS_DELAY"
},
"maxmind": {
"dbPath": "@@MAXMIND_DB_PATH",
"licenseKey": "@@MAXMIND_LICENSE_KEY",
"accountId": "@@MAXMIND_ACCOUNT_ID"
}
},
"client": {
"host": "@@CLIENT_HOST"
},
"db": {
"redis": {
"connectionString": "@@REDIS_CONNECTION_STRING"
},
"mongodb": {
"connectionString": "@@MONGODB_CONNECTION_STRING"
}
}
} In that file, we have 5 main configuration variables which we have to specify:
Now, we have two choices: either we can pass these values as environment variables, or we can put them directly in the file. In our current case, we will pass them as environment variables. Read more about the configuration of the Gateway and Dashboard here. We can now launch the server: # replace the following values with those relevant to your environment
DASHBOARD_PORT=8080 \
REDIS_CONNECTION_STRING="redis://localhost:6379" \
MONGODB_CONNECTION_STRING="mongodb://localhost:27017" \
DEFAULT_ADMIN_EMAIL="your_email" \
DEFAULT_ADMIN_PASSWORD="your_password" \
NODE_ENV=production yarn start:prod Once the server is launched, you can open the dashboard by going to http://localhost:8080 and login via admin credentials. AuthenticationYou can use Provide corresponding environment variables for enabling one of mail services. Sendgrid example: # replace the following values with those relevant to your environment and sendgrid account
MAIL_DRIVER="sendgrid" \
MAIL_FROM="[email protected]" \
SENDGRID_API_KEY="your_api_key" \
PUBLIC_HOST="dashboard_public_host" \
CLIENT_HOST="dashboard_frontend_host" \ SMTP example: # replace the following values with those relevant to your environment and smtp configuration
MAIL_DRIVER="smtp" \
MAIL_FROM="[email protected]" \
SMTP_HOST="smtp_host" \
SMTP_PORT="smtp_port" \
SMTP_USER="smtp_user" \
SMTP_PASS="smtp_pass" \
SMTP_SECURE="smtp_secure" \
PUBLIC_HOST="dashboard_public_host" \
CLIENT_HOST="dashboard_frontend_host" \
Sendgrid [DEPRECATED]. Use |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论