My dependencies are:
"@apollo/react-hooks": "^3.1.1",
"apollo-boost": "^0.4.4",
"graphql": "^14.5.6",
"react": "^16.9.0",
My query calling React component is:
import React from 'react'
import { useQuery } from '@apollo/react-hooks';
import { gql } from 'apollo-boost';
const FEED_QUERY = gql`
{
session(session_id: $id) {
session_id
event_type
}
}
`
function SessionDetails() {
const id = "web123";
const { loading, error, data } = useQuery(FEED_QUERY, {
variables: { id },
});
console.log(error)
console.log(data)
if (loading) return <div>Fetching</div>
if (error) return <div>Error</div>
const sessionsToRender = data.session
return (
<div>
{sessionsToRender.map(session => <Session key={session.session_id} session={session} />)}
</div>
)
}
I am getting error as "Network error: Response not successful: Received status code 400" and my data is undefined. The query is working properly in the GraphQL playground but not in the app. It seems that id is not being replaced. How do I fix it?
