我无法通过阿波罗查询连接到我的Prisma服务

时间:2019-05-22 23:13:13

标签: graphql prisma-graphql

我一直收到错误:

'request to http://localhost:4444/ failed, reason: connect 
     ECONNREFUSED 
     127.0.0.1:4444',
     type: 'system',
     errno: 'ECONNREFUSED',
     code: 'ECONNREFUSED' },




  const db = new Prisma({
  typeDefs: 'src/generated/prisma.graphql',
  endpoint: process.env.PRISMA_ENDPOINT,
  secret: process.env.PRISMA_SECRET,
  debug:false
 });
//This is my Prisma service that connects me to my Prisma database 


function createServer(){
  return new GraphQLServer({
    typeDefs:'src/schema.graphql',
    resolvers:{
      Mutation,
      Query
    },
    resolverValidationOptions:{
      requireResolversForResolveType:false
    },
    context:req => ({...req,db}),
  })
}
**This is my Server that sits on top of my Prisma service**

function createClient({ headers }) {
  return new ApolloClient({
    uri: process.env.NODE_ENV === 'development' ?endpoint : 
     endpoint,
    request: operation => {
      operation.setContext({
        fetchOptions: {
          credentials: 'include',
        },
        headers
      });
    },
  });
}
  **This is my apollo client which receives data from my server at 
  endpoint. This is were I'm having the error!**

server.start(
  {
    cors:{
      credentials:true,
      origin: process.env.FRONTEND_URL
    },

  },deets=>{
    console.log(`Server is now running on port 
      http:/localhost:${deets.port}`);
  }

)
**This gives me permission to request data from my server**


class Items extends Component{
  render(){
    return(
      <Center>
       <p>Items</p>
       <Query query={ALL_ITEMS_QUERY}>
        {({data,error,loading,})=>{
          if(loading) return <p>loading....</p>
          if(error) return <p>{error}</p>
          console.log(data);
          return<ItemsList>
           {data.items.map(item =>
             <p>{item.title}</p>
           )}
          </ItemsList>
        }}
        </Query>
       </Center>


    )
  }
}
**My apollo query to my data Prisma service**

............................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ................................................... ....................

request to http://localhost:4444/ failed, reason: connect ECONNREFUSED 127.0.0.1:4444', type: 'system', errno: 'ECONNREFUSED', code: 'ECONNREFUSED' },

0 个答案:

没有答案