URQL graphql query returning null in React Native

11 Views Asked by At

So I have a react native project with a node backend using URQL and nexus to generate a graphql schema .

I have a query useAllBillsQuery that for some reason only works when I am not authenticated (logged in as guest)

When i sign in with an authenitcated user, it returns null.

in Graphiql however, passing in the user ID makes no difference, it fetches my data no issue. The issue only appears in React Native.

My authentication is handled by a context provider, and I believe that is blocking the Query from being updated and running properly. Here is how my screen component looks:

gql`
  query AllBills($filter: BillsFilter, $userId: ID!) {
    bills(first: 50, filter: $filter) {
      nodes {
        id
        house
        number
        title
        headerImageUrl
        summary
        scheduledLegislativeDay
        introducedAt
        housePassageAt
        senatePassageAt
        enactedAt
        argumentsFor
        argumentsAgainst
        subjects {
          id
          name
        }
      }
    }



const BillsScreen: FC<StackScreenProps<MainStackParamList>> = ({
  navigation,
}) => {
  const {currentUser} = useContext(AppContext);
  const userId = currentUser?.id.toString() ?? '';


  const [{data}, executeQuery] = useAllBillsQuery({
    variables: {
      userId: userId,
    },
  });

I'm lead to believe this is a React Native issue rather than anything wrong with my grapqhl schema, however I'm stumped as to why this is happening.

0

There are 0 best solutions below