timhall / svelte-apollo

Svelte integration for Apollo GraphQL
MIT License
947 stars 68 forks source link

Query returns #64

Closed MirrorBytes closed 3 years ago

MirrorBytes commented 3 years ago

This is a weird issue to have, but when I query an array, it believes the returned data is under data and not data.<function_name>, here's an example:

Broken image

Functioning image

MirrorBytes commented 3 years ago

Related to functioning code:

image

timhall commented 3 years ago

That's definitely strange. data is returned exactly from @apollo/client so I'm not sure how that could happen. I'd need to see the GraphQL and how $forms is created to diagnose it

MirrorBytes commented 3 years ago

If I wrap it with an interface it works, such as:

  interface WrappedForm {
    get_forms: Form;
  }

  const form = query<WrappedForm>(client, {
    query: GET_FORMS,
    variables: {
      form: $params.id,
    },
  });

Now, this could have just been a slip by me since I use TS