Migrated from https://github.com/apollographql/react-apollo/pull/2825#issuecomment-468255909:
Hey @hwillson, after updating from 2.5.0 to 2.5.1 I am now getting empty responses after I've mocked apollo provider and passed my own resolvers. I am not using apollo-link-state anymore.
2.5.0 version returns proper result but it warns in console that:
Found @client directives in query but no client resolvers were specified. You can now pass apollo-link-state resolvers to the ApolloClient constructor.
Also if I pass null to resolvers in v2.5.1 it also works but still gives the warning.
Found @client directives in query but no client resolvers were specified. You can now pass apollo-link-state resolvers to the ApolloClient constructor.
I'm also getting this warning in a Nuxt project using apollo-client 2.5.1
Here the same. I have done migration from apollo-boost to apollo-client because I need to apply middleware.
I think this warning is necessary for apollo-boost, but I do not understand why I'm getting it in apollo-link.
If I rollback to version:
{
"dependencies": {
"apollo-client": "2.4.13"
}
}
I'm not getting this warning, it happens only from 2.5.0 version.
Has anyone been able to solve this ?
Am having same issue
A fix for this is in place, and will be coming in the next patch release of react-apollo
. I'll re-cap the changelog notes here:
MockedProvider
has been updated to stop setting a defaultresolvers
value of{}
, which means by default Apollo Client 2.5 local resolver
functionality is not enabled when mocking withMockedProvider
. This allows
@client
fields to be passed through the mocked link chain, like people
were used to before AC 2.5. When using this default mode you will see a
dev only warning message about this like:
Found @client directives in query but no client resolvers were specified. You can now pass apollo-link-state resolvers to the ApolloClient constructor.
This message can be safely ignored. If you want to use
MockedProvider
with AC 2.5's new local resolver functionality, you can pass your local
resolver map into theMockedProvider
resolvers
prop.
And just to add - the warning message above is going to change to the following, in the next patch release of Apollo Client (see https://github.com/apollographql/apollo-client/pull/4550 for details):
Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.
Also experiencing this issue.
Nothing on this?
I'm getting this warning "Found @client directives in query but no client resolvers were specified. You can now pass apollo-link-state resolvers to the ApolloClient constructor." for apparently no reason?
* EDIT *
Updated apollo-boost to ^0.3.1 which removed the warning.
If anyone gets here because of the console warning, without using MockedProvider
, update your local state management: https://www.apollographql.com/docs/react/essentials/local-state/#migrating-from-apollo-link-state
Having the same issue, everything is properly configured and my tests pass, but I get dozens of warnings about the @client directive in Jest
My tests don't pass and I get this error message, the query on MockedProvider
doesn't resolve the results.
Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain
Hi all, FWIW I am getting the same issue. Basically I am posting the following query:
query getTasks($item: ID!) {
record (id: $item) {
tasks @client {
id
name
state
deadline
}
}
}
Going through the source, I put a breakpoint on MockLink's requestToKey - and the query that it received was:
query getTasks($item: ID!) {
record (id: $item) {
__typename
}
}
Something in the pipeline is stripping the @client
fields away, making it impossible to mock them.
This is a problem, as I am using Storybook to simulate my components.
This appears to happen when the MockLink is created, not when it's queried - at that point, the queries seem to go through intact.
Anything about this am also getting the following warning
Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain
If you have local resolvers try adding them to your MockedProvider as follow
<MockedProvider resovlers={resolvers}>
<Component>
</MockedProvider>
So basically mock @client through sham resolvers?
On Thu, Aug 22, 2019, 6:21 PM Marouane Elaich notifications@github.com
wrote:
If you have local resolvers try adding them to your MockedProvider as
follow
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/apollographql/apollo-client/issues/4520?email_source=notifications&email_token=ABCJEF757PFRTVGQQFQK4Z3QF24JPA5CNFSM4G3IGZW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD45T5QQ#issuecomment-523976386,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABCJEFYNBGOXBF4DHXHTV5LQF24JPANCNFSM4G3IGZWQ
.
Same similar problem here.
I have this query:
export const GET_AVAILABLE_PLANS = gql`
query getAvailablePlans($areaId: Int!) {
availablePlans(areaId: $areaId) @client
}
`;
and on use this mock:
export const getAvailablePlansMock = {
request: {
query: GET_AVAILABLE_PLANS,
variables: { areaId },
},
result: {
data: {
availablePlans: [{
id: areaId,
name: 'Salem',
__typename: 'AvailablePlans',
}],
},
},
};
I didn't get any result.
Only using a resolver:
const resolvers = {
Query: {
availablePlans: () => getAvailablePlansMock.result.data.availablePlans,
},
};
I was able to get data.
This looks like an issue to me. resolver shouldn't be required if you specify the query result.
I was using:
"@apollo/client": "^3.2.5",
"storybook-addon-apollo-client": "^3.0.0",
Most helpful comment
If you have local resolvers try adding them to your MockedProvider as follow