with a long stack trace that includes the line with useQuery in it. Note that I do get the user’s email address printed to the console so I know Keycloak is working correctly. Here is the GET_USER query:
const GET_USER = gql`
query getUser($email: String) {
account(where: {email: $email}) {
company {
name
}
company_id
date_created
email
first_name
id
is_admin
last_name
}
}
`;
Any help is appriciated as I’ve been banging my head on this for a while.
Its difficult to tell what’s happening without more info on the error you’re seeing. Does that invariant violation have a URL thats attached that starts with https://go.apollo.dev/c/err? If so, please open that URL as it will give you more error details on what is happening.
And here’s the full code. I’m trying to use Keycloak for Authorization (that part is working as I get my email address printed in the console). It’s the code after the email is logged that’s causing the error and I can’t figure out why.
Your code user={UserComponent({ embeddedKeycloak: keycloakInstance })} is not actually rendering the UserComponent function as a component, but executes it as a function - as part of your Root component.
Your Root component is not wrapped in ApolloProvider (only it’s children are), so you get this error message.
You would need to actually render your UserComponent, like <UserComponent embeddedKeycloak={keycloakInstance} /> - passing that as a prop to App should be fine: