Skip to content

Commit b168ae8

Browse files
committed
docs(README): update example with realistic service and namespace names
1 parent 2dee4f1 commit b168ae8

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed

README.md

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,65 +56,74 @@ gql-federation-schema-parser parse -d ./schemas -s myService -n myScope --debug
5656

5757
With the following [schema files](./schemas) in a directory and these settings:
5858

59-
- `--service-name`: `myService`
60-
- `--namespace`: `myScope`
59+
- `--service-name`: `users`
60+
- `--namespace`: `platform`
6161

6262
The resulting GraphQL schema will be:
6363

6464
```graphql
6565
# Graphql root definitions
66-
type Query {
67-
myScope: NamespaceQueries!
68-
}
66+
directive @oneOf on INPUT_OBJECT
6967

70-
type Mutation {
71-
myScope: NamespaceMutations!
68+
scalar ID
69+
scalar String
70+
scalar Boolean
71+
72+
type PlatformUsers__Post {
73+
id: ID!
74+
content: String
75+
authorId: ID!
7276
}
7377

74-
type Subscription {
75-
myScope: NamespaceSubscriptions!
78+
type PlatformUsers__User {
79+
id: ID!
80+
name: String
81+
email: String
7682
}
7783

78-
# Namespace operations
79-
type NamespaceMutations {
80-
myService: myServiceMutations!
84+
type PlatformUsersQueries {
85+
posts: [PlatformUsers__Post!]!
86+
post(id: ID!): PlatformUsers__Post
87+
users: [PlatformUsers__User!]!
88+
getSubschemaData: String
8189
}
8290

83-
type NamespaceQueries {
84-
myService: myServiceQueries!
91+
type PlatformUsersMutations {
92+
createPost: PlatformUsers__Post!
8593
}
8694

87-
type NamespaceSubscriptions {
88-
myService: myServiceSubscriptions!
95+
type PlatformMutations {
96+
users: PlatformUsersMutations!
8997
}
9098

91-
# Service definitions
92-
type myServiceQueries {
93-
...
99+
type PlatformQueries {
100+
users: PlatformUsersQueries!
94101
}
95102

96-
type myServiceMutations {
97-
...
103+
type Mutation {
104+
platform: PlatformMutations!
98105
}
99106

100-
type ScopeSubscriptions {
101-
...
107+
type Query {
108+
platform: PlatformQueries!
102109
}
103110
```
104111

105112
In gateway you can query the schema like this:
106113

107114
```graphql
108115
query {
109-
myNamespace {
110-
myService {
116+
platform {
117+
users {
111118
# Query, mutate or subscribe to your service operations
112119
...
113120
}
114121
}
115122
}
116123
```
117124

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+
118127
### Where to use this tool
119128

120129
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

Comments
 (0)