You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the following [schema files](./schemas) in a directory and these settings:
58
58
59
-
-`--service-name`: `myService`
60
-
-`--namespace`: `myScope`
59
+
-`--service-name`: `users`
60
+
-`--namespace`: `platform`
61
61
62
62
The resulting GraphQL schema will be:
63
63
64
64
```graphql
65
65
# Graphql root definitions
66
-
typeQuery {
67
-
myScope: NamespaceQueries!
68
-
}
66
+
directive@oneOfonINPUT_OBJECT
69
67
70
-
typeMutation {
71
-
myScope: NamespaceMutations!
68
+
scalarID
69
+
scalarString
70
+
scalarBoolean
71
+
72
+
typePlatformUsers__Post {
73
+
id: ID!
74
+
content: String
75
+
authorId: ID!
72
76
}
73
77
74
-
typeSubscription {
75
-
myScope: NamespaceSubscriptions!
78
+
typePlatformUsers__User {
79
+
id: ID!
80
+
name: String
81
+
email: String
76
82
}
77
83
78
-
# Namespace operations
79
-
typeNamespaceMutations {
80
-
myService: myServiceMutations!
84
+
typePlatformUsersQueries {
85
+
posts: [PlatformUsers__Post!]!
86
+
post(id: ID!): PlatformUsers__Post
87
+
users: [PlatformUsers__User!]!
88
+
getSubschemaData: String
81
89
}
82
90
83
-
typeNamespaceQueries {
84
-
myService: myServiceQueries!
91
+
typePlatformUsersMutations {
92
+
createPost: PlatformUsers__Post!
85
93
}
86
94
87
-
typeNamespaceSubscriptions {
88
-
myService: myServiceSubscriptions!
95
+
typePlatformMutations {
96
+
users: PlatformUsersMutations!
89
97
}
90
98
91
-
# Service definitions
92
-
typemyServiceQueries {
93
-
...
99
+
typePlatformQueries {
100
+
users: PlatformUsersQueries!
94
101
}
95
102
96
-
typemyServiceMutations {
97
-
...
103
+
typeMutation {
104
+
platform: PlatformMutations!
98
105
}
99
106
100
-
typeScopeSubscriptions {
101
-
...
107
+
typeQuery {
108
+
platform: PlatformQueries!
102
109
}
103
110
```
104
111
105
112
Ingatewayyoucanquerytheschema like this:
106
113
107
114
```graphql
108
115
query {
109
-
myNamespace {
110
-
myService {
116
+
platform {
117
+
users {
111
118
# Query, mutate or subscribe to your service operations
112
119
...
113
120
}
114
121
}
115
122
}
116
123
```
117
124
125
+
All GraphQL types will be prefixed with the namespace and service name, allowing you to have multiple services under the same namespace without conflicts. Eg.: `PlatformUsers__User`, `PlatformUsers__Post`, etc.
126
+
118
127
### Where to use this tool
119
128
120
129
Use this CLI at the service level to prepare schema before publish it to the Schema Registry. It will generate a final GraphQL Schema file with the merged definitions. The gateway need to be prepared to translate the namespace and service name into the correct GraphQL operations at the service level.
0 commit comments