diff --git a/docs/.vuepress/components/HomeLayout.vue b/docs/.vuepress/components/HomeLayout.vue index c2eafa2..0dc164d 100644 --- a/docs/.vuepress/components/HomeLayout.vue +++ b/docs/.vuepress/components/HomeLayout.vue @@ -24,6 +24,12 @@ :item="actionLink" /> + Github + diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index be61091..f7f2667 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -1,6 +1,11 @@ +let ogprefix = 'og: http://ogp.me/ns#' +let title = 'Super Graph' +let description = 'An instant GraphQL API for your app. No code needed.' +let color = '#f42525' + module.exports = { - title: 'Super Graph', - description: 'Get an instant GraphQL API for your Rails apps.', + title: title, + description: description, themeConfig: { logo: '/hologram.svg', @@ -15,6 +20,22 @@ module.exports = { serviceWorker: { updatePopup: true }, + + head: [ + //['link', { rel: 'icon', href: `/assets/favicon.ico` }], + ['meta', { prefix: ogprefix, property: 'og:title', content: title }], + ['meta', { prefix: ogprefix, property: 'twitter:title', content: title }], + ['meta', { prefix: ogprefix, property: 'og:type', content: 'website' }], + ['meta', { prefix: ogprefix, property: 'og:url', content: 'https://supergraph.dev }], + ['meta', { prefix: ogprefix, property: 'og:description', content: description }], + //['meta', { prefix: ogprefix, property: 'og:image', content: 'https://wireupyourfrontend.com/assets/logo.png' }], + // ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }], + // ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }], + // ['link', { rel: 'apple-touch-icon', href: `/assets/apple-touch-icon.png` }], + // ['link', { rel: 'mask-icon', href: '/assets/safari-pinned-tab.svg', color: color }], + // ['meta', { name: 'msapplication-TileImage', content: '/assets/mstile-150x150.png' }], + // ['meta', { name: 'msapplication-TileColor', content: color }], + ], }, postcss: { diff --git a/docs/guide.md b/docs/guide.md index b842839..dc278f3 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -1149,11 +1149,11 @@ web_ui: true # debug, info, warn, error, fatal, panic log_level: "debug" -# Disable this in development to get a list of -# queries used. When enabled super graph -# will only allow queries from this list -# List saved to ./config/allow.list -use_allow_list: false +# When production mode is 'true' only queries +# from the allow list are permitted. +# When it's 'false' all queries are saved to the +# the allow list in ./config/allow.list +production: false # Throw a 401 on auth failure for queries that need auth auth_fail_block: false diff --git a/psql/query.go b/psql/query.go index f2c8c1b..92fa009 100644 --- a/psql/query.go +++ b/psql/query.go @@ -191,15 +191,15 @@ func (c *compilerContext) processChildren(sel *qcode.Select, ti *DBTableInfo) (u fallthrough case RelBelongTo: if _, ok := colmap[rel.Col2]; !ok { - cols = append(cols, &qcode.Column{ti.Name, rel.Col2, rel.Col2}) + cols = append(cols, &qcode.Column{Table: ti.Name, Name: rel.Col2, FieldName: rel.Col2}) } case RelOneToManyThrough: if _, ok := colmap[rel.Col1]; !ok { - cols = append(cols, &qcode.Column{ti.Name, rel.Col1, rel.Col1}) + cols = append(cols, &qcode.Column{Table: ti.Name, Name: rel.Col1, FieldName: rel.Col1}) } case RelRemote: if _, ok := colmap[rel.Col1]; !ok { - cols = append(cols, &qcode.Column{ti.Name, rel.Col1, rel.Col2}) + cols = append(cols, &qcode.Column{Table: ti.Name, Name: rel.Col1, FieldName: rel.Col2}) } skipped |= (1 << uint(id)) diff --git a/qcode/cleanup.sh b/qcode/cleanup.sh new file mode 100755 index 0000000..c46d6fb --- /dev/null +++ b/qcode/cleanup.sh @@ -0,0 +1,2 @@ +#!/bin/sh +cd corpus && rm -rf $(find . ! -name '00?.gql') diff --git a/qcode/qcode.go b/qcode/qcode.go index bd949eb..6d8cf9f 100644 --- a/qcode/qcode.go +++ b/qcode/qcode.go @@ -577,7 +577,7 @@ func (com *Compiler) compileArgID(sel *Select, arg *Arg) error { case nodeVar: ex.Type = ValVar default: - fmt.Errorf("expecting a string, int, float or variable") + return fmt.Errorf("expecting a string, int, float or variable") } sel.Where = ex diff --git a/serv/core.go b/serv/core.go index 06b88d8..a0ffe12 100644 --- a/serv/core.go +++ b/serv/core.go @@ -325,7 +325,7 @@ func (c *coreContext) resolveRemote( ob.WriteString("null") } - to[0] = jsn.Field{[]byte(s.FieldName), ob.Bytes()} + to[0] = jsn.Field{Key: []byte(s.FieldName), Value: ob.Bytes()} return to, nil } @@ -402,7 +402,7 @@ func (c *coreContext) resolveRemotes( ob.WriteString("null") } - to[n] = jsn.Field{[]byte(s.FieldName), ob.Bytes()} + to[n] = jsn.Field{Key: []byte(s.FieldName), Value: ob.Bytes()} }(i, id, s) } wg.Wait() diff --git a/tmpl/dev.yml b/tmpl/dev.yml index 1ac418f..42220ec 100644 --- a/tmpl/dev.yml +++ b/tmpl/dev.yml @@ -1,4 +1,4 @@ -app_name: "{{app_name}} Development" +app_name: "{% app_name %} Development" host_port: 0.0.0.0:8080 web_ui: true @@ -48,7 +48,7 @@ migrations_path: ./config/migrations auth: # Can be 'rails' or 'jwt' type: rails - cookie: _{{app_name_slug}}_session + cookie: _{% app_name_slug %}_session # Comment this out if you want to disable setting # the user_id via a header for testing. @@ -84,7 +84,7 @@ database: type: postgres host: db port: 5432 - dbname: {{app_name_slug}}_development + dbname: {% app_name_slug %}_development user: postgres password: '' diff --git a/tmpl/prod.yml b/tmpl/prod.yml index f0ada67..c2c6f3f 100644 --- a/tmpl/prod.yml +++ b/tmpl/prod.yml @@ -2,7 +2,7 @@ # so I only need to overwrite some values inherits: dev -app_name: "{{app_name}} Production" +app_name: "{% app_name %} Production" host_port: 0.0.0.0:8080 web_ui: false @@ -47,7 +47,7 @@ enable_tracing: true auth: # Can be 'rails' or 'jwt' type: rails - cookie: _{{app_name_slug}}_session + cookie: _{% app_name_slug %}_session rails: # Rails version this is used for reading the @@ -78,7 +78,7 @@ database: type: postgres host: db port: 5432 - dbname: {{app_name_slug}}_development + dbname: {% app_name_slug %}_development user: postgres password: '' #pool_size: 10