I'm trying to send GraphQL queries to a mssql database utilizing the Apollo SQL datasource. I believe the error is in the configuration object, since it's recognizing that I'm trying to access the database. I tried looking through the knex documentation (since that's the library that the Apollo SQL datasource uses) but it doesn't have that much information about MSSQL implementation. I also tried installing tedious like it says to in the documentation, but I'm not sure how I would utilize it with the configuration object. Has anybody encountered something similar when trying to send GraphQL queries to a mssql database through apollo-server-express?
**index.js**
const db = require('./datasources/db');
const dbConfig = {
client: 'mssql',
connection: {
domain: <domain>,
server: <server>,
driver: <driver>,
database: <dbname>,
port: <port>,
user: <user>,
password: <pw>,
requestTimeout: <timeout>,
options: {
encrypt: false,
enableArithAbort: false
}
}
}
const database = new db(dbConfig);
...
async function startApolloServer() {
const httpServer = http.createServer(app);
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
dataSources: () => ({ database })
});
await server.start();
server.applyMiddleware({ app });
await new Promise(resolve => httpServer.listen({ port: httpListenerPort }, resolve));
console.log(` Server ready at http://localhost:${port}${server.graphqlPath}`);
return { server, app };
}
startApolloServer();
error message: Login failed for user '<user>'.