Skip to content

Commit

Permalink
Merge pull request #88 from mercurius-js/feature/upgrade-fastify-v4
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnydgreen authored Jul 6, 2022
2 parents 9871452 + 52935cb commit b6f9756
Show file tree
Hide file tree
Showing 36 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

### External Policy mode
Expand Down Expand Up @@ -181,7 +181,7 @@ app.register(mercuriusAuth, {
}
})

app.listen(3000)
app.listen({ port: 3000 })
```

## Examples
Expand Down
2 changes: 1 addition & 1 deletion bench/gateway-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const query = `query {

const instance = autocannon(
{
url: 'http://localhost:3000/graphql',
url: 'http://127.0.0.1:3000/graphql',
connections: 100,
title: '',
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion bench/gateway-service-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ app.register(mercurius, {
jit: 1
})

app.listen(3001)
app.listen({ port: 3001 })
2 changes: 1 addition & 1 deletion bench/gateway-service-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ app.register(mercurius, {
jit: 1
})

app.listen(3002)
app.listen({ port: 3002 })
6 changes: 3 additions & 3 deletions bench/gateway-with-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ app.register(mercurius, {
gateway: {
services: [{
name: 'user',
url: 'http://localhost:3001/graphql'
url: 'http://127.0.0.1:3001/graphql'
}, {
name: 'post',
url: 'http://localhost:3002/graphql'
url: 'http://127.0.0.1:3002/graphql'
}]
},
graphiql: false,
Expand All @@ -32,4 +32,4 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
6 changes: 3 additions & 3 deletions bench/gateway-without-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ app.register(mercurius, {
gateway: {
services: [{
name: 'user',
url: 'http://localhost:3001/graphql'
url: 'http://127.0.0.1:3001/graphql'
}, {
name: 'post',
url: 'http://localhost:3002/graphql'
url: 'http://127.0.0.1:3002/graphql'
}]
},
graphiql: false,
jit: 1
})

app.listen(3000)
app.listen({ port: 3000 })
2 changes: 1 addition & 1 deletion bench/normal-bench-introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const query = `query {

const instance = autocannon(
{
url: 'http://localhost:3000/graphql',
url: 'http://127.0.0.1:3000/graphql',
connections: 100,
title: '',
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion bench/normal-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const query = `query {

const instance = autocannon(
{
url: 'http://localhost:3000/graphql',
url: 'http://127.0.0.1:3000/graphql',
connections: 100,
title: '',
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion bench/normal-with-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
2 changes: 1 addition & 1 deletion bench/normal-with-introspection-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ app.register(mercuriusAuth, {
filterSchema: true
})

app.listen(3000)
app.listen({ port: 3000 })
2 changes: 1 addition & 1 deletion bench/normal-without-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ app.register(mercurius, {
jit: 1
})

app.listen(3000)
app.listen({ port: 3000 })
4 changes: 2 additions & 2 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

## Run multiple auth plugins at the same time
Expand Down Expand Up @@ -172,5 +172,5 @@ app.register(mercuriusAuth, {
authDirective: 'auth2'
})

app.listen(3000)
app.listen({ port: 3000 })
```
4 changes: 2 additions & 2 deletions docs/api/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

### External Policy mode
Expand Down Expand Up @@ -216,5 +216,5 @@ app.register(mercuriusAuth, {
}
})

app.listen(3000)
app.listen({ port: 3000 })
```
4 changes: 2 additions & 2 deletions docs/apply-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

## External Policy mode
Expand Down Expand Up @@ -169,5 +169,5 @@ app.register(mercuriusAuth, {
}
})

app.listen(3000)
app.listen({ port: 3000 })
```
4 changes: 2 additions & 2 deletions docs/auth-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

## Usage without `authContext`
Expand Down Expand Up @@ -113,7 +113,7 @@ async function start () {
}
})

app.listen(3000)
app.listen({ port: 3000 })
}

start()
Expand Down
6 changes: 3 additions & 3 deletions docs/auth-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

The auth directive can also be use at the type level, to wrap all fields of a type (useful when working with federated types). You can nest auth directives this way as well to protect certain types/fields of a parent type.
Expand Down Expand Up @@ -111,7 +111,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

## Multiple Directives
Expand Down Expand Up @@ -186,5 +186,5 @@ app.register(mercuriusAuth, {
authDirective: 'hasPermission'
})

app.listen(3000)
app.listen({ port: 3000 })
```
4 changes: 2 additions & 2 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```

### Returning the custom error in the `applyPolicy` function
Expand Down Expand Up @@ -162,7 +162,7 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
```
### Status Code
Mercurius defaults all errors with the HTTP 500 status code. You can customize this property by using the built-in `ErrorWithProps` custom error provided by the underlining Mercurius plug-in
Expand Down
8 changes: 4 additions & 4 deletions docs/federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function createService (schema, resolvers = {}) {
resolvers,
federationMetadata: true
})
await service.listen(0)
await service.listen({ port: 0 })
return [service, service.server.address().port]
}

Expand Down Expand Up @@ -153,10 +153,10 @@ async function start (authOpts) {
gateway: {
services: [{
name: 'user',
url: `http://localhost:${userServicePort}/graphql`
url: `http://127.0.0.1:${userServicePort}/graphql`
}, {
name: 'post',
url: `http://localhost:${postServicePort}/graphql`
url: `http://127.0.0.1:${postServicePort}/graphql`
}]
}
})
Expand All @@ -173,7 +173,7 @@ async function start (authOpts) {
authDirective: 'auth'
})

await gateway.listen(3000)
await gateway.listen({ port: 3000 })
}

start()
Expand Down
2 changes: 1 addition & 1 deletion docs/schema-filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ app.register(mercuriusAuth, {
}
})

app.listen(3000)
app.listen({ port: 3000 })
```

After starting the server, you can use the following GraphQL query to test the filtering:
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ app.register(mercuriusAuth, {
authDirective: 'orgAuth'
})

app.listen(3000)
app.listen({ port: 3000 })
2 changes: 1 addition & 1 deletion examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
2 changes: 1 addition & 1 deletion examples/custom-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ app.register(mercuriusAuth, {
authDirective: 'auth'
})

app.listen(3000)
app.listen({ port: 3000 })
2 changes: 1 addition & 1 deletion examples/external-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ app.register(mercuriusAuth, {
}
})

app.listen(3000)
app.listen({ port: 3000 })
8 changes: 4 additions & 4 deletions examples/gateway-with-auth-on-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function createService (schema, resolvers = {}) {
},
authDirective: 'auth'
})
await service.listen(0)
await service.listen({ port: 0 })
return [service, service.server.address().port]
}

Expand Down Expand Up @@ -176,7 +176,7 @@ async function start () {
gateway: {
services: [{
name: 'user',
url: `http://localhost:${userServicePort}/graphql`,
url: `http://127.0.0.1:${userServicePort}/graphql`,
rewriteHeaders: (headers, context) => {
if (headers['x-user']) {
return {
Expand All @@ -187,7 +187,7 @@ async function start () {
}
}, {
name: 'post',
url: `http://localhost:${postServicePort}/graphql`,
url: `http://127.0.0.1:${postServicePort}/graphql`,
rewriteHeaders: (headers, context) => {
if (headers['x-user']) {
return {
Expand All @@ -201,7 +201,7 @@ async function start () {
graphiql: true
})

await gateway.listen(3000)
await gateway.listen({ port: 3000 })
}

start()
8 changes: 4 additions & 4 deletions examples/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function createService (schema, resolvers = {}) {
resolvers,
federationMetadata: true
})
await service.listen(0)
await service.listen({ port: 0 })
return [service, service.server.address().port]
}

Expand Down Expand Up @@ -148,10 +148,10 @@ async function start (authOpts) {
gateway: {
services: [{
name: 'user',
url: `http://localhost:${userServicePort}/graphql`
url: `http://127.0.0.1:${userServicePort}/graphql`
}, {
name: 'post',
url: `http://localhost:${postServicePort}/graphql`
url: `http://127.0.0.1:${postServicePort}/graphql`
}]
}
})
Expand All @@ -168,7 +168,7 @@ async function start (authOpts) {
authDirective: 'auth'
})

await gateway.listen(3000)
await gateway.listen({ port: 3000 })
}

start()
2 changes: 1 addition & 1 deletion examples/multiple-auth-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ app.register(mercuriusAuth, {
authDirective: 'auth2'
})

app.listen(3000)
app.listen({ port: 3000 })
2 changes: 1 addition & 1 deletion examples/no-auth-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function start () {
}
})

app.listen(3000)
app.listen({ port: 3000 })
}

start()
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const plugin = fp(
},
{
name: 'mercurius-auth',
fastify: '>=3.x',
fastify: '4.x',
dependencies: ['mercurius']
}
)
Expand Down
Loading

0 comments on commit b6f9756

Please sign in to comment.