Skip to content

nktks/gql-spansql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gql-spansql

gql-spansql is a command-line tool to convert GraphQL SDL to Google Cloud Spanner table schemas.

Install

go install github.com/nakatamixi/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);

About

Generate Spanner Schema from GraphQL SDL

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages