Closed q3e closed 6 years ago
Similar issue https://github.com/apollographql/react-docs/issues/56
even if using 2 queries and fetching at the same time. it still would show the error because for every user search, there is an organization search error
graphql(
queries.fetchUser,
{
name: "fetchUser",
options: ({ navigation: { state: { params: { username }}} }) => ({ variables: { login: username } }),
notifyOnNetworkStatusChange: true
}
),
graphql(
// the GraphQL document
queries.fetchOrg,
// the config object
{
name: "fetchOrg", // attaches response of this query to props of component not the general data prop
// compute options from props - query variable computed from the navigation prop
options: ({ navigation: { state: { params: { username }}} }) => ({ variables: { login: username } }),
notifyOnNetworkStatusChange: true
}
)
Just learned that there is a __typename
node in REPOSITORY search query for github API. That should close this flippin issue. Coming ...
The RepoOwnerProfile component that renders a github user profile. The apollo HoC wrapper did inject the correct query variable. However doesnt make sense why
user
is missing from the data For example if the variable isfacebook
, its successfully added to the data prop from the query fetch but query results don't contain the actual user profile offacebook
` import React from 'react' import { View, Text } from 'react-native' import gql from 'graphql-tag' import { graphql } from 'react-apollo'
const RepoOwnerProfile = ({ data, navigation: { state: { params: { username } } } }) => { console.log(data) return Profile @{username}
}
const getUserProfile = gql
query getUserProfile($login:String!){ user(login: $login) { name bio avatarUrl followers { totalCount } starredRepositories { totalCount } following{ totalCount } repositories{ totalCount } } }
export default graphql(getUserProfile, { options: ({ navigation: { state: { params: { username }}} }) => ({ variables: { login: username } }), notifyOnNetworkStatusChange: true })(RepoOwnerProfile) `