Apollo-client-devtools: Incorrect work with `extend` in Query and Mutation

Created on 14 Dec 2018  ยท  9Comments  ยท  Source: apollographql/apollo-client-devtools

Hello all! Have few questions/bugs/features with extend keyword in version 2.1.5

1) Queries declared with extend not seen in devtools
image
image

2) when locally try to extend existing queries from server, have error Must provide schema definition with query type or a type named Query.
can we remove this check or add functionality to work when all queries extends Query?

steps to reproduce:
1) add any endpoint to ApolloClient
2) add one type def that extends Query

const typeDef = gql`
  extend type Query {
    users: [User]
  }
`;

result error: Must provide schema definition with query type or a type named Query.
but code is valid and works well

I can not create type Query without extending because it breaks validations

Any thoughts?

needs-reproduction ๐Ÿž bug

Most helpful comment

Thank you @raedle ! There was a change going from rc2 โ†’ rc3 that changed how the Apollo Client DevTools access Apollo Client's local typeDefs. That explains why it didn't work with the alpha versions! Thanks for following up and letting me know things are working now!

All 9 comments

Thanks for opening an issue @VasiliKubarka ! Can you take a look at my comments here: https://github.com/apollographql/apollo-client-devtools/issues/132#issuecomment-462415551. Would #1 qualify as a reproduction for what you're seeing? If so, I'll mark this is a duplicate of #132. If not, can you please provide a reproduction?

Relates to #132

@justinanastos Hello, thanks for reply, don't think that it's the same behavior that I faced.
Anyway I tested this on 2.1.8 version, and for this version both client typeDefs with type Query... and extend type Query are not shown in Documentation Explorer in Query type.
I checked that in both your apollo-pre branch and alfa master branch

export const typeDefs = gql`
  extend type Query {
    isLoggedIn: Boolean!
    cartItems: [Launch]!
  }

  extend type Launch {
    isInCart: Boolean!
  }

  extend type Mutation {
    addOrRemoveFromCart(id: ID!): [Launch]
  }
`;

For example in both versions isLoggedIn and cartItems are not shown in queries list
image

but as I described before, client typeDefs has been shown in 2.1.5 version if where written without extend keyword

So can you please describe, what is expected behavior for reflection client typeDefs in devTools?

We've added all local state to GraphiQL with v2.2.0. This works for apollo-client/react-apollo v2.4 and v2.5 that was released today!

I've updated to v2.2.0 and it does not show the local schema (using it together with [email protected]).

Can anyone confirm that the local schema shows up in the Documentation Explorer in v2.2.0?

Can you give any more details @raedle ? I checked out the full stack tutorial, ran the apps in final/client and final/server. Note the typeDefs definition here:

https://github.com/apollographql/fullstack-tutorial/blob/014d900d62265a1c69825cb82367b2e838e05f2a/final/client/src/resolvers.js#L4-L17

and the inclusion of those typeDefs in the ApolloClient constructor here:

https://github.com/apollographql/fullstack-tutorial/blob/014d900d62265a1c69825cb82367b2e838e05f2a/final/client/src/index.js#L18-L30

I see the local schema extensions in the Documentation Explorer and there are no warnings given about either the local fields or the @client directive in the query input panel.

image

Thanks @justinanastos for your quick response. I tried the fullstack tutorial, but even with this one I don't see the local schema in the Documentation Explorer.

I even installed the Apollo Client Dev Tools extension on a clean Google Chrome account, but still no local schema.

apollo-client-dev-tools

I'm using Google Chrome Version 72.0.3626.119 and the Apollo Client Dev Tools v2.2.0 from the Google Marketplace.

@raedle Are you on the latest version of the fullstack tutorial with the latest dependencies installed in final/client and final/server?

To check:

cd final/client
npm ls apollo-client react-apollo
$ cd final/client
$ npm ls apollo-client react-apollo
[email protected] xxx/fullstack-tutorial/final/client
โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected]

What do you see?

It works after updating both packages to v2.5.1.

In my own project, I had both packages at v2.5.0, and the fullstack was on [email protected] and [email protected].

Thanks you!

Thank you @raedle ! There was a change going from rc2 โ†’ rc3 that changed how the Apollo Client DevTools access Apollo Client's local typeDefs. That explains why it didn't work with the alpha versions! Thanks for following up and letting me know things are working now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kissu picture kissu  ยท  4Comments

raix picture raix  ยท  7Comments

nanandn picture nanandn  ยท  4Comments

richburdon picture richburdon  ยท  4Comments

mvestergaard picture mvestergaard  ยท  6Comments