-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.graphql
More file actions
97 lines (91 loc) · 2.99 KB
/
schema.graphql
File metadata and controls
97 lines (91 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
type Task
@auth(
query: {
rule: """
query($USER: String!) {
queryTask {
user(filter: { username: { eq: $USER } }) {
__typename
}
}
}
"""
}
) {
id: ID!
title: String! @search(by: [fulltext])
completed: Boolean! @search
user: User!
}
type User {
username: String! @id @search(by: [hash])
name: String @search(by: [exact])
tasks: [Task] @hasInverse(field: user)
}
# How to use the auth rule - In this case everyone can query the users ranking but
type UserRank
@withSubscription # This enables the subscription for this type and anyone can wait subscribe to changes of this type
@auth(
add: { rule: "{$roles: { eq: \"superadmin\" } }" }
delete: { rule: "{$roles: { eq: \"superadmin\" } }" }
update: { rule: "{$roles: { eq: \"superadmin\" } }" }
) {
UserRankID: ID!
user: User!
rank: Float!
created_at: DateTime @search
updated_at: DateTime @search
}
# Example of how to use or condition for multiple roles
type Posts
@auth(
add: {
or: [
{ rule: "{$roles: { eq: \"operator\" } }" }
{ rule: "{$roles: { eq: \"admin\" } }" }
{ rule: "{$roles: { eq: \"superadmin\" } }" }
]
}
delete: {
or: [
{ rule: "{$roles: { eq: \"operator\" } }" }
{ rule: "{$roles: { eq: \"admin\" } }" }
{ rule: "{$roles: { eq: \"superadmin\" } }" }
]
}
update: {
or: [
{ rule: "{$roles: { eq: \"operator\" } }" }
{ rule: "{$roles: { eq: \"admin\" } }" }
{ rule: "{$roles: { eq: \"superadmin\" } }" }
]
}
) {
PostID: ID
title: String!
content: String!
}
# Example of having some of the GraphQL operations disabled for a type
type Error
@generate( # How to disable delete and update mutations for this type
query: { get: true, query: true, aggregate: true }
mutation: { add: true, delete: false, update: false }
subscription: true
) {
ErrorID: ID!
errorDetail: String
errorDateTime: DateTime @search
}
# Example of using the @lambdaOnMutate directive to call a lambda function on a mutation
# https://dgraph.io/docs/graphql/lambda/mutation/#schema
type Author {
id: ID!
name: String! @search(by: [hash, trigram])
dob: DateTime
reputation: Float
}
type Mutation {
newAuthor(name: String!): ID! @lambda
}
# #example of using pub, private: Dgraph.Authorization X-Auth-Token https://dgraph.io/jwt/claims RS256 "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp/qw/KXH23bpOuhXzsDp\ndo9bGNqjd/OkH2LkCT0PKFx5i/lmvFXdd04fhJD0Z0K3pUe7xHcRn1pIbZWlhwOR\n7siaCh9L729OQjnrxU/aPOKwsD19YmLWwTeVpE7vhDejhnRaJ7Pz8GImX/z/Xo50\nPFSYdX28Fb3kssfo+cMBz2+7h1prKeLZyDk30ItK9MMj9S5y+UKHDwfLV/ZHSd8m\nVVEYRXUNNzLsxD2XaEC5ym2gCjEP1QTgago0iw3Bm2rNAMBePgo4OMgYjH9wOOuS\nVnyvHhZdwiZAd1XtJSehORzpErgDuV2ym3mw1G9mrDXDzX9vr5l5CuBc3BjnvcFC\nFwIDAQAB\n-----END PUBLIC KEY-----"
# Dgraph.Authorization X-Auth-Token https://dgraph.io/jwt/claims HS256 "qwertyuiopasdfghjklzxcvbnm123456"