Skip to content

Commit 0517b1b

Browse files
committed
go with camelCase anywhere
1 parent f8a9381 commit 0517b1b

20 files changed

+248
-248
lines changed

benchmark/composed-schema.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const requestOptions = {
1818

1919
export function setup() {
2020
let data = {
21-
type_defs: 'type Query { hello: String }',
21+
typeDefs: 'type Query { hello: String }',
2222
version: '1',
23-
graph_name: 'my_graph',
24-
service_name: 'foo',
23+
graphName: 'my_graph',
24+
serviceName: 'foo',
2525
}
2626
let res = http.post(`${BASE_URL}/schema/push`, JSON.stringify(data), requestOptions)
2727

@@ -34,10 +34,10 @@ export function setup() {
3434
}
3535

3636
data = {
37-
type_defs: 'type Query { world: String }',
37+
typeDefs: 'type Query { world: String }',
3838
version: '1',
39-
graph_name: 'my_graph',
40-
service_name: 'bar',
39+
graphName: 'my_graph',
40+
serviceName: 'bar',
4141
}
4242
res = http.post(`${BASE_URL}/schema/push`, JSON.stringify(data), requestOptions)
4343

@@ -52,7 +52,7 @@ export function setup() {
5252

5353
export default () => {
5454
const data = {
55-
graph_name: 'my_graph',
55+
graphName: 'my_graph',
5656
services: [
5757
{ name: 'foo', version: '1' },
5858
{ name: 'bar', version: '1' },

docs/api.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GET - `/graphs` Returns all registered graphs.
88

99
### Get latest schemas
1010

11-
GET - `/schema/latest?graph_name=my_graph` Returns the last registered schema definition of all services.
11+
GET - `/schema/latest?graphName=my_graph` Returns the last registered schema definition of all services.
1212

1313
### Register a schema
1414

@@ -20,10 +20,10 @@ POST - `/schema/push` Creates a new graph and schema for a service.
2020

2121
```jsonc
2222
{
23-
"type_defs": "type Query { hello: String }",
23+
"typeDefs": "type Query { hello: String }",
2424
"version": "1",
25-
"graph_name": "my_graph",
26-
"service_name": "foo"
25+
"graphName": "my_graph",
26+
"serviceName": "foo"
2727
}
2828
```
2929

@@ -40,7 +40,7 @@ POST - `/schema/compose` Returns the last registered schema definition of all se
4040

4141
```jsonc
4242
{
43-
"graph_name": "my_graph",
43+
"graphName": "my_graph",
4444
"services": [{ "name": "foo", "version": "1" }] // if versions can't be found it fails
4545
}
4646
```
@@ -77,9 +77,9 @@ POST - `/schema/diff` Returns the schema report of all services and the provided
7777

7878
```json
7979
{
80-
"graph_name": "my_graph",
81-
"type_defs": "type Query { hello: String }",
82-
"service_name": "foo"
80+
"graphName": "my_graph",
81+
"typeDefs": "type Query { hello: String }",
82+
"serviceName": "foo"
8383
}
8484
```
8585

@@ -96,9 +96,9 @@ POST - `/schema/validate` Validate schema between provided and latest schemas.
9696

9797
```json
9898
{
99-
"graph_name": "my_graph",
100-
"type_defs": "type Query { hello: String }",
101-
"service_name": "foo"
99+
"graphName": "my_graph",
100+
"typeDefs": "type Query { hello: String }",
101+
"serviceName": "foo"
102102
}
103103
```
104104

insomnia.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/core/basic-auth.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ test('Should return 200 because credentials are valid', async (t) => {
1818
method: 'POST',
1919
url: '/schema/push',
2020
payload: {
21-
type_defs: `type Query { world: String }`,
21+
typeDefs: `type Query { world: String }`,
2222
version: '2',
23-
service_name: `${t.context.testPrefix}_bar`,
24-
graph_name: `${t.context.graphName}`,
23+
serviceName: `${t.context.testPrefix}_bar`,
24+
graphName: `${t.context.graphName}`,
2525
},
2626
headers: {
2727
authorization: 'Basic MTIzOjEyMw==', // 123
@@ -42,10 +42,10 @@ test('Should support multiple secrets comma separated', async (t) => {
4242
method: 'POST',
4343
url: '/schema/push',
4444
payload: {
45-
type_defs: `type Query { world: String }`,
45+
typeDefs: `type Query { world: String }`,
4646
version: '3',
47-
service_name: `${t.context.testPrefix}_bar`,
48-
graph_name: `${t.context.graphName}`,
47+
serviceName: `${t.context.testPrefix}_bar`,
48+
graphName: `${t.context.graphName}`,
4949
},
5050
headers: {
5151
authorization: 'Basic NDU2OjQ1Ng==', // 456

src/core/hook-handler/user-scope.prevalidation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FastifyRequest, FastifyReply, HookHandlerDoneFunction } from 'fastify'
22
import { InvalidServiceScopeError } from '../errrors'
33

44
export interface RequestContext {
5-
Body: { service_name: string }
5+
Body: { serviceName: string }
66
}
77

88
/**
@@ -14,9 +14,9 @@ export const checkUserServiceScope = function (
1414
next: HookHandlerDoneFunction,
1515
) {
1616
// JWT context ?
17-
if (req.user && req.body.service_name) {
18-
if (!req.user.services.find((service) => service === req.body.service_name)) {
19-
return next(InvalidServiceScopeError(req.body.service_name))
17+
if (req.user && req.body.serviceName) {
18+
if (!req.user.services.find((service) => service === req.body.serviceName)) {
19+
return next(InvalidServiceScopeError(req.body.serviceName))
2020
}
2121
}
2222
next()

src/registry/federation/deactivate-schema.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ test('Should deactivate schema', async (t) => {
1717
method: 'POST',
1818
url: '/schema/push',
1919
payload: {
20-
type_defs: `type Query { hello: String }`,
20+
typeDefs: `type Query { hello: String }`,
2121
version: '1',
22-
service_name: `${t.context.testPrefix}_foo`,
23-
graph_name: `${t.context.graphName}`,
22+
serviceName: `${t.context.testPrefix}_foo`,
23+
graphName: `${t.context.graphName}`,
2424
},
2525
})
2626
t.is(res.statusCode, 200)
@@ -32,7 +32,7 @@ test('Should deactivate schema', async (t) => {
3232
url: '/schema/deactivate',
3333
payload: {
3434
schemaId,
35-
graph_name: `${t.context.graphName}`,
35+
graphName: `${t.context.graphName}`,
3636
},
3737
})
3838

@@ -42,7 +42,7 @@ test('Should deactivate schema', async (t) => {
4242
method: 'POST',
4343
url: '/schema/compose',
4444
payload: {
45-
graph_name: `${t.context.graphName}`,
45+
graphName: `${t.context.graphName}`,
4646
services: [
4747
{
4848
name: `${t.context.testPrefix}_foo`,
@@ -75,7 +75,7 @@ test('Should return 400 when schema does not exist', async (t) => {
7575
url: '/schema/deactivate',
7676
payload: {
7777
schemaId: 123,
78-
graph_name: `${t.context.graphName}`,
78+
graphName: `${t.context.graphName}`,
7979
},
8080
})
8181

src/registry/federation/deactivate-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SchemaRepository from '../../core/repositories/SchemaRepository'
66
export interface RequestContext {
77
Body: {
88
schemaId: number
9-
graph_name: string
9+
graphName: string
1010
}
1111
}
1212

src/registry/federation/get-composed-schema-versions.test.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ test('Should return schema of two services', async (t) => {
1717
method: 'POST',
1818
url: '/schema/push',
1919
payload: {
20-
type_defs: `type Query { hello: String }`,
20+
typeDefs: `type Query { hello: String }`,
2121
version: '1',
22-
service_name: `${t.context.testPrefix}_foo`,
23-
graph_name: `${t.context.graphName}`,
22+
serviceName: `${t.context.testPrefix}_foo`,
23+
graphName: `${t.context.graphName}`,
2424
},
2525
})
2626
t.is(res.statusCode, 200)
@@ -29,10 +29,10 @@ test('Should return schema of two services', async (t) => {
2929
method: 'POST',
3030
url: '/schema/push',
3131
payload: {
32-
type_defs: `type Query { world: String }`,
32+
typeDefs: `type Query { world: String }`,
3333
version: '2',
34-
service_name: `${t.context.testPrefix}_bar`,
35-
graph_name: `${t.context.graphName}`,
34+
serviceName: `${t.context.testPrefix}_bar`,
35+
graphName: `${t.context.graphName}`,
3636
},
3737
})
3838
t.is(res.statusCode, 200)
@@ -41,10 +41,10 @@ test('Should return schema of two services', async (t) => {
4141
method: 'POST',
4242
url: '/schema/push',
4343
payload: {
44-
type_defs: `type Query { world: String }`,
44+
typeDefs: `type Query { world: String }`,
4545
version: '3',
46-
service_name: `${t.context.testPrefix}_bar`,
47-
graph_name: `${t.context.graphName}`,
46+
serviceName: `${t.context.testPrefix}_bar`,
47+
graphName: `${t.context.graphName}`,
4848
},
4949
})
5050
t.is(res.statusCode, 200)
@@ -53,7 +53,7 @@ test('Should return schema of two services', async (t) => {
5353
method: 'POST',
5454
url: '/schema/compose',
5555
payload: {
56-
graph_name: `${t.context.graphName}`,
56+
graphName: `${t.context.graphName}`,
5757
services: [
5858
{
5959
name: `${t.context.testPrefix}_bar`,
@@ -87,10 +87,10 @@ test('Should return latest schema when no version was specified', async (t) => {
8787
method: 'POST',
8888
url: '/schema/push',
8989
payload: {
90-
type_defs: `type Query { hello: String }`,
90+
typeDefs: `type Query { hello: String }`,
9191
version: '1',
92-
service_name: `${t.context.testPrefix}_foo`,
93-
graph_name: `${t.context.graphName}`,
92+
serviceName: `${t.context.testPrefix}_foo`,
93+
graphName: `${t.context.graphName}`,
9494
},
9595
})
9696
t.is(res.statusCode, 200)
@@ -99,10 +99,10 @@ test('Should return latest schema when no version was specified', async (t) => {
9999
method: 'POST',
100100
url: '/schema/push',
101101
payload: {
102-
type_defs: `type Query { world: String }`,
102+
typeDefs: `type Query { world: String }`,
103103
version: '2',
104-
service_name: `${t.context.testPrefix}_bar`,
105-
graph_name: `${t.context.graphName}`,
104+
serviceName: `${t.context.testPrefix}_bar`,
105+
graphName: `${t.context.graphName}`,
106106
},
107107
})
108108
t.is(res.statusCode, 200)
@@ -111,10 +111,10 @@ test('Should return latest schema when no version was specified', async (t) => {
111111
method: 'POST',
112112
url: '/schema/push',
113113
payload: {
114-
type_defs: `type Query { world: String }`,
114+
typeDefs: `type Query { world: String }`,
115115
version: '3',
116-
service_name: `${t.context.testPrefix}_bar`,
117-
graph_name: `${t.context.graphName}`,
116+
serviceName: `${t.context.testPrefix}_bar`,
117+
graphName: `${t.context.graphName}`,
118118
},
119119
})
120120
t.is(res.statusCode, 200)
@@ -123,7 +123,7 @@ test('Should return latest schema when no version was specified', async (t) => {
123123
method: 'POST',
124124
url: '/schema/compose',
125125
payload: {
126-
graph_name: `${t.context.graphName}`,
126+
graphName: `${t.context.graphName}`,
127127
services: [
128128
{
129129
name: `${t.context.testPrefix}_foo`,
@@ -165,10 +165,10 @@ test('Should return 404 when schema in version could not be found', async (t) =>
165165
method: 'POST',
166166
url: '/schema/push',
167167
payload: {
168-
type_defs: `type Query { hello: String }`,
168+
typeDefs: `type Query { hello: String }`,
169169
version: '1',
170-
service_name: `${t.context.testPrefix}_foo`,
171-
graph_name: `${t.context.graphName}`,
170+
serviceName: `${t.context.testPrefix}_foo`,
171+
graphName: `${t.context.graphName}`,
172172
},
173173
})
174174
t.is(res.statusCode, 200)
@@ -177,7 +177,7 @@ test('Should return 404 when schema in version could not be found', async (t) =>
177177
method: 'POST',
178178
url: '/schema/compose',
179179
payload: {
180-
graph_name: `${t.context.graphName}`,
180+
graphName: `${t.context.graphName}`,
181181
services: [
182182
{
183183
name: `${t.context.testPrefix}_foo`,
@@ -209,10 +209,10 @@ test('Should return 400 when schema in specified version was deactivated', async
209209
method: 'POST',
210210
url: '/schema/push',
211211
payload: {
212-
type_defs: `type Query { hello: String }`,
212+
typeDefs: `type Query { hello: String }`,
213213
version: '1',
214-
service_name: `${t.context.testPrefix}_foo`,
215-
graph_name: `${t.context.graphName}`,
214+
serviceName: `${t.context.testPrefix}_foo`,
215+
graphName: `${t.context.graphName}`,
216216
},
217217
})
218218
t.is(res.statusCode, 200)
@@ -224,7 +224,7 @@ test('Should return 400 when schema in specified version was deactivated', async
224224
url: '/schema/deactivate',
225225
payload: {
226226
schemaId,
227-
graph_name: `${t.context.graphName}`,
227+
graphName: `${t.context.graphName}`,
228228
},
229229
})
230230

@@ -234,7 +234,7 @@ test('Should return 400 when schema in specified version was deactivated', async
234234
method: 'POST',
235235
url: '/schema/compose',
236236
payload: {
237-
graph_name: `${t.context.graphName}`,
237+
graphName: `${t.context.graphName}`,
238238
services: [
239239
{
240240
name: `${t.context.testPrefix}_foo`,

src/registry/federation/get-composed-schema-versions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface ServiceVersionMatch {
1515

1616
export interface RequestContext {
1717
Body: {
18-
graph_name: string
18+
graphName: string
1919
services: ServiceVersionMatch[]
2020
}
2121
}
@@ -40,8 +40,8 @@ export const schema: FastifySchema = {
4040
},
4141
body: S.object()
4242
.additionalProperties(false)
43-
.required(['graph_name', 'services'])
44-
.prop('graph_name', S.string().minLength(1).pattern('[a-zA-Z_\\-0-9]+'))
43+
.required(['graphName', 'services'])
44+
.prop('graphName', S.string().minLength(1).pattern('[a-zA-Z_\\-0-9]+'))
4545
.prop(
4646
'services',
4747
S.array()
@@ -60,11 +60,11 @@ export default function getComposedSchemaVersions(fastify: FastifyInstance) {
6060
const graphRepository = new GraphRepository(fastify.knex)
6161

6262
const graphExists = await graphRepository.exists({
63-
name: req.body.graph_name,
63+
name: req.body.graphName,
6464
})
6565

6666
if (!graphExists) {
67-
throw InvalidGraphNameError(req.body.graph_name)
67+
throw InvalidGraphNameError(req.body.graphName)
6868
}
6969

7070
const serviceRepository = new ServiceRepository(fastify.knex)
@@ -77,7 +77,7 @@ export default function getComposedSchemaVersions(fastify: FastifyInstance) {
7777

7878
const schmemaService = new SchemaManager(serviceRepository, schemaRepository)
7979
const { schemas, error: findError } = await schmemaService.findByServiceVersions(
80-
req.body.graph_name,
80+
req.body.graphName,
8181
allServicesWithVersion,
8282
)
8383

0 commit comments

Comments
 (0)