Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

TypeError: mergeTypeDefs is not a function

Olá! Uma ajuda por favor!

Eu instalei o módulo graphql-tools e criei o código abaixo, conforme mostrado na aula:

const { ApolloServer } = require('apollo-server') const { mergeTypeDefs } = require('graphql-tools') const path = require('path')

const userSchema = require('./user/schema/user.graphql') const userResolvers = require('./user/resolvers/userResolvers') const UsersAPI = require('./user/datasource/user')

const turmaSchema = require('./turma/schema/turma.graphql') const turmaResolvers = require('./turma/resolvers/turmaResolvers') //const TurmasAPI = require('./turma/datasource/turma')

const typeDefs = mergeTypeDefs([userSchema, turmaSchema]) const resolvers = [userResolvers, turmaResolvers]

const server = new ApolloServer({ typeDefs, resolvers, dataSources: () => { return { usersAPI: new UsersAPI() } } });

server.listen().then(({url}) => { console.log(Server ready at ${url}); })

Porém estou recebendo um erro:

[nodemon] restarting due to changes... [nodemon] starting node ./api/index.js This package has been deprecated and now it only exports makeExecutableSchema. And it will no longer receive updates. We recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc. Check out https://www.graphql-tools.com to learn what package you should use instead! /home/node/app/api/index.js:13 const typeDefs = mergeTypeDefs([userSchema, turmaSchema]) ^

TypeError: mergeTypeDefs is not a function at Object. (/home/node/app/api/index.js:13:18) at Module.compile (internal/modules/cjs/loader.js:1076:30) at Object.Module.extensions..js (internal/modules/cjs/loader.js:1097:10) at Module.load (internal/modules/cjs/loader.js:941:32) at Function.Module.load (internal/modules/cjs/loader.js:782:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/runmain.js:72:12) at internal/main/run_main_module.js:17:47 [nodemon] app crashed - waiting for file changes before starting...

Favor. O que será que estou fazendo de errado?

Obrigado!

1 resposta