Shopify Daisy(Database Integration System) is a system for continuously replicating data from Shopify to the databases.
- Apollo Server: HTTP server for GraphQL APIs
- GraphQL Nexus: GraphQL schema definition and resolver implementation
- Prisma Client: Databases access (ORM)
- Prisma Migrate: Database migrations
- SQLite: Local, file-based SQL database
Clone the entire repo
Clone this repository:
git clone git@github.com:datadlog/shopify-daisy.git --depth=1
Install npm dependencies:
cd shopify-daisy
npm install
Run the following command to create your SQLite database file. This also create the Customer
table that are defined in prisma/schema.prisma
:
npx prisma migrate dev --name init
Now, seed the database with the sample data in prisma/seed.ts
by running the following command:
npx prisma db seed
Launch your GraphQL server with this command:
npm run dev
Navigate to http://localhost:4000 in your browser to explore the API of your GraphQL server in a GraphQL Playground.
The schema that specifies the API operations of your GraphQL server is defined in ./schema.graphql
. Below are a number of operations that you can send to the API using the GraphQL Playground.
Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features.
query {
allCustomers {
email
first_name
last_name
state
}
}
mutation {
createCustomer(data: { first_name: "Naveen", email: "naveen@datadlog.com" }) {
id
}
}
If you want to try this example with another database than SQLite, you can adjust the the database connection in prisma/schema.prisma
by reconfiguring the datasource
block.
Learn more about the different connection configurations in the docs.
Expand for an overview of example configurations with different databases
For PostgreSQL, the connection URL has the following structure:
datasource db {
provider = "postgresql"
url = "postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA"
}
Here is an example connection string with a local PostgreSQL database:
datasource db {
provider = "postgresql"
url = "postgresql://janedoe:mypassword@localhost:5432/notesapi?schema=public"
}
For MySQL, the connection URL has the following structure:
datasource db {
provider = "mysql"
url = "mysql://USER:PASSWORD@HOST:PORT/DATABASE"
}
Here is an example connection string with a local MySQL database:
datasource db {
provider = "mysql"
url = "mysql://janedoe:mypassword@localhost:3306/notesapi"
}
Here is an example connection string with a local Microsoft SQL Server database:
datasource db {
provider = "sqlserver"
url = "sqlserver://localhost:1433;initial catalog=sample;user=sa;password=mypassword;"
}
Here is an example connection string with a local MongoDB database:
datasource db {
provider = "mongodb"
url = "mongodb://USERNAME:PASSWORD@HOST/DATABASE?authSource=admin&retryWrites=true&w=majority"
}
Because MongoDB is currently in Preview, you need to specify the previewFeatures
on your generator
block:
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongodb"]
}