Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make it work using vue-apollo #129

Open
FrancescoMussi opened this issue Dec 21, 2021 · 0 comments
Open

Cannot make it work using vue-apollo #129

FrancescoMussi opened this issue Dec 21, 2021 · 0 comments

Comments

@FrancescoMussi
Copy link

FrancescoMussi commented Dec 21, 2021

Hello,
I am trying to make it working, but unsuccesfully.
Could you be so kind to check it out?

I am using @vue/apollo-composable 4.0.0-alpha.16

This is my code:

import { GetCountry , Country} from '../generated/graphql'

setup() {
  const route = useRoute()
  const code = route.params.code

  const { result, loading } = useQuery(GetCountry, {code: code}, { 
    clientId: 'default', 
    fetchPolicy: 'cache-first'
  });
  const country: Country = useResult(result, {}, (data) => data.country);
  console.log(country.continent)

  return {
    country,
    loading
  }
}

By assigning the type Country to the const country I get the following error:
Type 'Readonly<Ref<Readonly<any>>>' is missing the following properties from type 'Country': code, continent, emoji, emojiU, and 5 more.

This is Country and GetCountry from the generated code:

export type Country = {
  __typename?: 'Country';
  capital?: Maybe<Scalars['String']>;
  code: Scalars['ID'];
  continent: Continent;
  currency?: Maybe<Scalars['String']>;
  emoji: Scalars['String'];
  emojiU: Scalars['String'];
  languages: Array<Language>;
  name: Scalars['String'];
  native: Scalars['String'];
  phone: Scalars['String'];
  states: Array<State>;
};


export const GetCountry = gql`
    query getCountry($code: ID!) {
  country(code: $code) {
    code
    name
    native
    phone
    capital
    currency
    emoji
    continent {
      code
      name
    }
    languages {
      code
      name
    }
    states {
      code
      name
    }
  }
}

Am I doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant