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

Incorrect work with extend in Query and Mutation #159

Closed
VasiliKubarka opened this issue Dec 14, 2018 · 9 comments
Closed

Incorrect work with extend in Query and Mutation #159

VasiliKubarka opened this issue Dec 14, 2018 · 9 comments

Comments

@VasiliKubarka
Copy link

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?

@VasiliKubarka VasiliKubarka changed the title Incorrect work with extend for Query Incorrect work with extend in Query and Mutation Dec 14, 2018
@justinanastos
Copy link
Contributor

Thanks for opening an issue @VasiliKubarka ! Can you take a look at my comments here: #132 (comment). 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

@VasiliKubarka
Copy link
Author

@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?

@justinanastos
Copy link
Contributor

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!

@raedle
Copy link

raedle commented Feb 27, 2019

I've updated to v2.2.0 and it does not show the local schema (using it together with apollo-client@2.5.0).

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

@justinanastos
Copy link
Contributor

justinanastos commented Feb 27, 2019

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

@justinanastos justinanastos reopened this Feb 27, 2019
@raedle
Copy link

raedle commented Feb 27, 2019

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.

@justinanastos
Copy link
Contributor

@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
client@0.1.0 xxx/fullstack-tutorial/final/client
├── apollo-client@2.5.1
└── react-apollo@2.5.1

What do you see?

@raedle
Copy link

raedle commented Feb 27, 2019

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 apollo-client@2.5.0-alpha.10 and react-apollo@2.4.0-alpha.3.

Thanks you!

@justinanastos
Copy link
Contributor

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!

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

No branches or pull requests

3 participants