https://github.com/nktks/gql-spansql
Generate Spanner Schema from GraphQL SDL
https://github.com/nktks/gql-spansql
google-cloud-spanner graphql spanner
Last synced: about 2 months ago
JSON representation
Generate Spanner Schema from GraphQL SDL
- Host: GitHub
- URL: https://github.com/nktks/gql-spansql
- Owner: nktks
- License: mit
- Created: 2021-06-09T07:10:11.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T00:24:44.000Z (about 2 years ago)
- Last Synced: 2025-06-01T09:52:34.351Z (about 1 year ago)
- Topics: google-cloud-spanner, graphql, spanner
- Language: Go
- Homepage:
- Size: 87.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gql-spansql
[license]: https://github.com/nktks/gql-spansql/blob/master/LICENSE
`gql-spansql` is a command-line tool to convert GraphQL SDL to Google Cloud Spanner table schemas.
# Install
```
go install github.com/nktks/gql-spansql/cmd/gql-spansql
```
# Usage
```
Usage:
-column-case string
snake or lowercamel or uppercamel. if empty no convert.
-created-column-name string
if not empty, add this column as created_at Timestamp column.
-loose
loose type check.
-s string
path to input schama
-table-case string
snake or lowercamel or uppercamel. if empty no convert.
-updated-column-name string
if not empty, add this column as updated_at Timestamp column.
```
# Example
```
cat internal/converter/testdata/spanner_sql.gql
type User {
userId: ID!
state: State!
time: Time!
}
type Item {
itemId: ID!
}
enum State {
ENABLED
DISABLED
}
scalar Time
type Query {
user(user_id: ID): User
}
type Mutation {
user(user_id: ID!, state: State): User
}
type Subscription {
user(user_id: ID): User
}
go run cmd/main.go -s internal/converter/testdata/spanner_sql.gql
CREATE TABLE Item (
itemId STRING(MAX) NOT NULL,
) PRIMARY KEY(itemId);
CREATE TABLE User (
userId STRING(MAX) NOT NULL,
state INT64 NOT NULL,
time TIMESTAMP NOT NULL,
) PRIMARY KEY(userId);
```