Skip to Content

Configure SQLServer DataSource

Published: 2022-05-23

To configure SQLServer as a DataSource, you have to use introspection. Import the introspect function from the @wundergraph/sdk. It should be available if you have initialized your project with wunderctl init.

Make sure to use the correct syntax to define the database URL.

import {
introspect,
} from "@wundergraph/sdk";
const api = introspect.sqlserver({
apiNamespace: "db",
databaseURL: "sqlserver://localhost:1433;database=wundergraph;schema=wg;user=SA;password=secure_Password;encrypt=true;trustServerCertificate=true",
})

Pass a valid SQLServer URL as an argument to introspect.sqlserver. This gives you a Promise of an API object. This db object can now be passed to an Application. This way, you're able to combine the generated GraphQL API of the database with other APIs, e.g. a REST or another GraphQL API.

const myApplication = new Application({
name: "app",
apis: [
db,
],
})

Product

Comparisons

Subscribe to our newsletter!

Stay informed when great things happen! Get the latest news about APIs, GraphQL and more straight into your mailbox.

© 2022 WunderGraph