Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mercurius

Package Overview
Dependencies
Maintainers
2
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mercurius - npm Package Compare versions

Comparing version 10.0.0 to 10.1.0

test/gateway/set-response-headers.js

1

docs/api/options.md

@@ -73,2 +73,3 @@ # mercurius

- `service.rewriteHeaders`: `Function` A function that gets the original headers as a parameter and returns an object containing values that should be added to the headers
- `service.setResponseHeaders`: `Function` A function that gets `reply` as a parameter and can be used to set headers for the federated response to be sent to the client.
- `service.initHeaders`: `Function` or `Object` An object or a function that returns the headers sent to the service for the initial \_service SDL query.

@@ -75,0 +76,0 @@ - `service.connections`: The number of clients to create. (Default: `10`)

@@ -185,2 +185,5 @@ # mercurius

}
},
setResponseHeaders: (reply) => {
reply.header('set-cookie', 'sessionId=12345')
}

@@ -187,0 +190,0 @@ },

2

docs/integrations/open-telemetry.md

@@ -7,3 +7,3 @@ # mercurius

Here is a simple exemple on how to enable tracing on Mercurius with OpenTelemetry:
Here is a simple example on how to enable tracing on Mercurius with OpenTelemetry:

@@ -10,0 +10,0 @@ tracer.js

@@ -5,5 +5,5 @@ # Integrating Prisma with Mercurius

It can be used as an _alternative_ to writing plain SQL, or using another database access tool such as SQL query builders (e.g. [knex.js](https://knexjs.org/)) or ORMs (like [TypeORM](https://typeorm.io/) and [Sequelize](https://sequelize.org/)).
Prisma currently supports PostgreSQL, MySQL, SQL Server and SQLite.
Prisma currently supports PostgreSQL, MySQL, SQL Server, MongoDB, CockroachDB, and SQLite.
You can easily combine Prisma and Mercurius to build your GraphQL server that connects to a database. Prisma is agnostic to the GraphQL tools you use when building your GraphQL server.
You can easily combine Prisma and Mercurius to build your GraphQL server that connects to a database. Prisma is agnostic to the GraphQL tools you use when building your GraphQL server. Check out this [GitHub repo](https://github.com/2color/fastify-graphql-nexus-prisma) for a ready-to-run example project with a PosgreSQL database.

@@ -17,4 +17,4 @@ Prisma can be used with plain JavaScript and it embraces TypeScript and provides a level to type-safety that goes beyond the guarantees other ORMs in the TypeScript ecosystem. You can find an in-depth comparison of Prisma against other ORMs [here](https://www.prisma.io/docs/concepts/more/comparisons)

```bash
npm install prisma@2.20.1 --save-dev
npm install @prisma/client@2.20.1
npm install prisma --save-dev
npm install @prisma/client
```

@@ -24,4 +24,2 @@

> **Note**: Prisma releases typically happen every two weeks with a minor version update.
Initialize Prisma in your project:

@@ -38,8 +36,9 @@ ```bash

To connect to your database, set the `url` field of the `datasource` block in your Prisma schema to your database connection URL. By default, it's set to `postgresql` but this guide will use SQLite database. Adjust your `datasource` block to `sqlite` and `url` to `file:./dev.db`:
To connect to your database, set the `url` field of the `datasource` block in your Prisma schema to your database connection URL. By default, it's set to `postgresql` but this guide will use SQLite database. Adjust your `datasource` block to `sqlite`:
```prisma
/// prisma/schema.prisma
datasource db {
provider = "sqlite"
url = "file:./dev.db"
url = env("DATABASE_URL")
}

@@ -52,3 +51,11 @@

Update the `DATABASE_URL` environment variable in the `.env` file:
```
# .env
DATABASE_URL="file:./dev.db"
```
If you wish to use a different database, you can jump to [switching database providers](#switching-database-providers).
## Create database tables with Prisma Migrate

@@ -75,2 +82,3 @@

1. Creates a new SQL migration file for this migration
1. Creates the database if it does not exist
1. Runs the SQL migration against the database

@@ -171,13 +179,5 @@ 1. Generates Prisma Client

Here's an overview of an example configuration with different databases:
### PostgreSQL
For PostgreSQL, the connection URL has the following structure:
```prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
```
Here is an example connection string with a local PostgreSQL database:

@@ -194,3 +194,3 @@

For MySQL, the connection URL has the following structure:
Here is an example connection string with a local MySQL database:

@@ -204,7 +204,9 @@ ```prisma

Here is an example connection string with a local MySQL database:
### SQL Server
Here is an example connection string with a local Microsoft SQL Server database:
```prisma
datasource db {
provider = "mysql"
provider = "sqlserver"
url = env("DATABASE_URL")

@@ -214,3 +216,3 @@ }

### SQLServer (preview)
### CockroachDB

@@ -221,3 +223,3 @@ Here is an example connection string with a local Microsoft SQL Server database:

datasource db {
provider = "sqlserver"
provider = "cockroachdb"
url = env("DATABASE_URL")

@@ -227,9 +229,11 @@ }

Because SQL Server is currently in [Preview](https://www.prisma.io/docs/about/releases#preview), you need to specify the `previewFeatures` on your `generator` block:
### MongoDB
Here is an example connection string with a local Microsoft SQL Server database:
```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["microsoftSqlServer"]
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
```
```

@@ -177,3 +177,6 @@ 'use strict'

name: 'user',
url: 'http://localhost:4001/graphql'
url: 'http://localhost:4001/graphql',
setResponseHeaders: (reply) => {
reply.header('abc', 'abc')
}
}, {

@@ -180,0 +183,0 @@ name: 'post',

@@ -401,2 +401,3 @@ import {

| WsConnectionParams;
setResponseHeaders?: (reply:FastifyReply) => void;
}

@@ -403,0 +404,0 @@

@@ -500,2 +500,4 @@ 'use strict'

service.setResponseHeaders(reply)
const transformed = transformData(response)

@@ -502,0 +504,0 @@ // TODO support union types

@@ -73,3 +73,3 @@ 'use strict'

try {
const { body, statusCode } = await request({
const { body, statusCode, headers } = await request({
url,

@@ -98,3 +98,4 @@ method: 'POST',

statusCode,
json
json,
headers
}

@@ -101,0 +102,0 @@ } catch (err) {

@@ -124,2 +124,3 @@ 'use strict'

sendRequest: sendRequest(request, url, useSecureParse),
setResponseHeaders: (reply) => opts.setResponseHeaders ? opts.setResponseHeaders(reply) : null,
close,

@@ -126,0 +127,0 @@ async refresh () {

@@ -74,3 +74,3 @@ 'use strict'

}
this.queue.destroy()
this.queue.push(null)
}

@@ -77,0 +77,0 @@ }

@@ -14,2 +14,3 @@ 'use strict'

if (socket.protocol === undefined || getProtocolByName(socket.protocol) === null) {
request.log.warn('wrong websocket protocol')
// Close the connection with an error code, ws v2 ensures that the

@@ -16,0 +17,0 @@ // connection is cleaned up even when the closing handshake fails.

{
"name": "mercurius",
"version": "10.0.0",
"version": "10.1.0",
"description": "Fastify GraphQL adapter with gateway and subscription support",

@@ -36,3 +36,3 @@ "main": "index.js",

"@sinonjs/fake-timers": "^9.0.0",
"@types/node": "^17.0.0",
"@types/node": "^18.0.0",
"@types/ws": "^8.2.0",

@@ -53,3 +53,3 @@ "@types/isomorphic-form-data": "^2.0.0",

"tap": "^16.0.0",
"tsd": "^0.20.0",
"tsd": "^0.22.0",
"typescript": "^4.3.5",

@@ -68,3 +68,3 @@ "wait-on": "^6.0.0"

"p-map": "^4.0.0",
"readable-stream": "^3.6.0",
"readable-stream": "^4.0.0",
"safe-stable-stringify": "^2.3.0",

@@ -71,0 +71,0 @@ "secure-json-parse": "^2.4.0",

@@ -366,2 +366,18 @@ import { expectAssignable, expectError } from 'tsd'

gateway.register(mercurius, {
gateway: {
services: [
{
name: 'user',
url: 'http://localhost:4001/graphql',
schema: `
type Query {
dogs: [Dog]
}`,
setResponseHeaders: (reply) => reply.header('abc', 'abc')
}
]
}
})
expectError(() => gateway.register(mercurius, {

@@ -377,2 +393,18 @@ gateway: {

}`,
setResponseHeaders: false
}
]
}
}))
expectError(() => gateway.register(mercurius, {
gateway: {
services: [
{
name: 'user',
url: 'http://localhost:4001/graphql',
schema: `
type Query {
dogs: [Dog]
}`,
keepAlive: true

@@ -379,0 +411,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc