Compare commits

...

2 Commits

Author SHA1 Message Date
6716b97a39 fix: duplicate fragment crash issue 2020-06-07 17:03:09 -04:00
7169dd65f5 docs: add firebase auth and fragments 2020-06-07 15:58:00 -04:00
8 changed files with 67 additions and 35 deletions

View File

@ -330,8 +330,6 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
return nil, fmt.Errorf("unexpected token: %s", p.peekNext())
}
// fm := make(map[uint64]struct{})
for {
if p.peek(itemEOF) {
p.ignore()
@ -384,23 +382,10 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
n := int32(len(fields))
fields = append(fields, fr.Fields...)
for i := int(n); i < len(fields); i++ {
f := &fields[i]
f.ID = int32(i)
// var name string
// if f.Alias != "" {
// name = f.Alias
// } else {
// name = f.Name
// }
// if _, ok := fm[name]; ok {
// continue
// } else {
// fm[name] = struct{}{}
// }
for i := 0; i < len(fr.Fields); i++ {
k := (n + int32(i))
f := &fields[k]
f.ID = int32(k)
// If this is the top-level point the parent to the parent of the
// previous field.
@ -415,6 +400,9 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
f.ParentID += n
}
f.Children = make([]int32, len(f.Children))
copy(f.Children, fr.Fields[i].Children)
// Update all the children which is needed.
for j := range f.Children {
f.Children[j] += n
@ -433,20 +421,6 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
return nil, err
}
// var name string
// if f.Alias != "" {
// name = f.Alias
// } else {
// name = f.Name
// }
// if _, ok := fm[name]; ok {
// continue
// } else {
// fm[name] = struct{}{}
// }
if st.Len() == 0 {
f.ParentID = -1
} else {

View File

@ -450,7 +450,6 @@ func (com *Compiler) compileQuery(qc *QCode, op *Operation, role string) error {
}
col := Column{Name: f.Name, FieldName: fname}
s.Cols = append(s.Cols, col)
}

View File

@ -55,6 +55,30 @@ query {
}
```
### Fragments
Fragments make it easy to build large complex queries with small composible and re-usable fragment blocks.
```graphql
query {
users {
...userFields2
...userFields1
picture_url
}
}
fragment userFields1 on user {
id
email
}
fragment userFields2 on user {
first_name
last_name
}
```
### Sorting
To sort or ordering results just use the `order_by` argument. This can be combined with `where`, `search`, etc to build complex queries to fit you needs.

View File

@ -4,6 +4,8 @@ title: Introduction
sidebar_label: Introduction
---
import useBaseUrl from '@docusaurus/useBaseUrl'; // Add to the top of the file below the front matter.
Super Graph is a service that instantly and without code gives you a high performance and secure GraphQL API. Your GraphQL queries are auto translated into a single fast SQL query. No more spending weeks or months writing backend API code. Just make the query you need and Super Graph will do the rest.
Super Graph has a rich feature set like integrating with your existing Ruby on Rails apps, joining your DB with data from remote APIs, Role and Attribute based access control, Support for JWT tokens, DB migrations, seeding and a lot more.
@ -134,3 +136,9 @@ mutation {
}
}
```
### Built-in GraphQL Editor
Quickly craft and test your queries with a full-featured GraphQL editor. Auto-complete and schema documentation is automatically available.
<img alt="Zipkin Traces" src={useBaseUrl("img/webui.jpg")} />

View File

@ -95,7 +95,7 @@ auth:
type: jwt
jwt:
# the two providers are 'auth0' and 'none'
# valid providers are auth0, firebase and none
provider: auth0
secret: abc335bfcfdb04e50db5bb0a4d67ab9
public_key_file: /secrets/public_key.pem
@ -108,6 +108,19 @@ We can get the JWT token either from the `authorization` header where we expect
For validation a `secret` or a public key (ecdsa or rsa) is required. When using public keys they have to be in a PEM format file.
### Firebase Auth
```yaml
auth:
type: jwt
jwt:
provider: firebase
audience: <firebase-project-id>
```
Firebase auth also uses JWT the keys are auto-fetched from Google and used according to their documentation mechanism. The `audience` config value needs to be set to your project id and everything else is taken care for you.
### HTTP Headers
```yaml

View File

@ -0,0 +1,13 @@
---
id: webui
title: Web UI / GraphQL Editor
sidebar_label: Web UI
---
import useBaseUrl from '@docusaurus/useBaseUrl'; // Add to the top of the file below the front matter.
<img alt="Zipkin Traces" src={useBaseUrl("img/webui.jpg")} />
Super Graph comes with a build-in GraphQL editor that only runs in development. Use it to craft your queries and copy-paste them into you're app once you're ready. The editor supports auto-completation and schema documentation. This makes it super easy to craft and test your query all in one go without knowing anything about the underlying database structure.
You can even set query variables or http headers as required. To simulate an authenticated user set the http header `"X-USER-ID": 5` to the user id of the user you want to test with.

View File

@ -3,6 +3,7 @@ module.exports = {
Docusaurus: [
"home",
"intro",
"webui",
"start",
"why",
"graphql",

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB