61
loading...
This website collects cookies to deliver better user experience
stepzen login
What is your account name?: {ACCOUNT}
What is your admin key?: {ADMINKEY}
mkdir mysql-stepzen
cd mysql-stepzen
stepzen import mysql
? What would you like your endpoint to be called? api/dozing-sheep
Created /Users/luciacerchie/project-folder/stepzen.config.json
Downloading from StepZen...... done
stepzen.config.json
file, which will hold the name of your endpoint.? What is your host? host_address_here
? What is your database name? database_name_here
? What is the username? username_here
? What is the password? [hidden]
Finding these inputs in your dsn string can be a little tricky, as the dsn strings might have slightly different formats depending on how you've chosen to deploy, but in general you will have something like this pattern:
mysql://{{USERNAME}}:{{PASSWORD}}@{{HOST}}:{{port}}/{{DATABASE_NAME}}
.
├── _mysql
│ └── mysql.graphql
├── config.yaml
├── index.graphql
└── stepzen.config.json
stepzen.config.json
, which I've mentioned before. It will look something like:{
"endpoint": "api/dozing-sheep"
}
index.graphql
, which will look like:schema @sdl(files: ["mysql/mysql.graphql"]) {
query: Query
}
index.graphql
martials the schemas for StepZen. If you had more than one, it would appear in the files: []
brackets as part of a comma-separated list of strings.config.yaml
will look like:configurationset:
- configuration:
name: mysql_config
dsn: {{USERNAME}}:{{PASSWORD}}@{{HOST}}:{{port}}/{{DATABASE_NAME}}
NOTE: Make sure config.yaml
is in your .gitignore
before pushing to any git branches.
mysql/mysql.graphql
, you will find a schema like:type Countries {
GDPUSD: Int
country_name: String!
id: String
isoCode: String
}
type Query {
getCountriesList: [Countries]
@dbquery(type: "mysql", table: "countries", configuration: "mysql_config")
}
Countries
from your countries table, and the query type getCountriesList returns all the information on the countries in that table, in the mode of a SELECT * FROM...
SQL command.stepzen start
. The Schema Explorer will open up at localhost:5000/api/foldername
in your browser:query MyQuery {
getCountriesList {
GDPUSD
country_name
id
isoCode
}
}
{
"data": {
"getCountriesList": [
{
"GDPUSD": 19,
"country_name": "Afghanistan",
"id": "Q889",
"isoCode": "AFN"
},
{
"GDPUSD": 23,
"country_name": "Zambia",
"id": "Q953",
"isoCode": "ZMW"
},
{
"GDPUSD": 207,
"country_name": "New Zealand",
"id": "Q664",
"isoCode": "NZD"
},
{
"GDPUSD": 15,
"country_name": "Mozambique",
"id": "Q1029",
"isoCode": "MZN"
}