-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Unsure how to resolve Missing field while writing result
error when using subscriptions
#8677
Comments
yeah I can confirm I have the same issue on initial page subscription, using Vue + ActionCable subscribeToMore(() => ({
document: USER_APP_CREATED,
variables: {
gravatarSize: 24,
},
updateQuery: (oldData, { subscriptionData }) => {
if (Object.keys(subscriptionData.data).length === 0) {
return { ...oldData };
} stacktrace:
|
also having this issue since upgrading from 3.4-beta-0 to 3.4.10 |
i have the same issue, using |
@blehoux17 I agree this is not an actionable or useful warning (in this particular case), and we should find a way to hide it. I'm collecting various subscription-related issues using this label, in case you have any others you think deserve a(nother) look. Hopefully this issue will get fixed in the process, but I've labeled it to be sure. |
I too am seeing this error surface after upgrading this morning... Original versions.
Upgraded versions.
|
Also getting this error now (after upgrading) while executing |
Also getting the error using
|
Getting the same issue with apollo-client Here is the relevant line in the source code, for those wondering:
Not really sure what I'm supposed to do to resolve the issue. (I know one way to solve it is to make sure the server returns a value for every field that Apollo is aware of; however I don't want to have to do that, because the field is already marked as optional in the GraphQL defined on the server, so I want Apollo to be compatible with that without needing server-side workarounds) EDIT: Found a temporary fix:
EDIT2: Nevermind, that seems not to have fixed it -- at least not reliably. |
Same. |
same |
Hitting this too since we upgraded to |
same using |
+1 - |
+1 same |
same issue |
Running into this on "@apollo/client": "^3.4.16" |
Maybe it helps someone facing that in tests: It happened with me because a mocked resolver had an exception inside. |
I think I can make the error go away by making the field optional in my type Subscription {
"""
this field shows the error
"""
joinedSession(sessionId: ID!): JoinedSessionPayload!
"""
this one doesn't
"""
leftSession(sessionId: ID!): LeftSessionPayload
} In my case, I'm using I do still get an HTH! |
Today it is not working 😔 |
So what's a fix to this problem ? I don't know if you experience the same behaviour, but my subscription doesn't subscribe because of this , which is quite a major problem .... |
The same issue - |
It seems like there is no ability to have an empty subscription mock, for when we want to only test a Query. If the subscription isn't included in the mocks prop provided to MockedProvider, I get: If the subscription is included but with no data. something like this:
Then Apollo will complain with: Can we get someway of ignoring subscriptions or providing a empty mock, to fix this error? |
Hi everyone! I faced this issue a few weeks ago. In my case, the error was produced by a missing property in a mocked object used by a test. E.g.: Error:
Mocked object:
In this example, the 'name' property was missing in the mock used by the test, which has a type of:
Solution: Make the property optional, or add a mocked value for the mocked object |
Hi everyone still facing this issue after upgrading
If anyone has a working fix, please kindly share. |
Not sure if it's the best solution but this eliminated the error: error is: updateQuery: (prev, { subscriptionData }) => {
if (Object.keys(prev || {}).length === 0) {
// there's nothing in cache, return empty array otherwise crash!
return { chat_channel: [] }; <---------- instead of return prev;
} |
+1 same |
+1 same |
I previously solved this issue here: #8677 (comment) But now it has come back because of a subscription that doesn't contain the full object, only updated parts.
Apollo, for unknown reasons, complains about It also just appeared a few days ago but I don't remember upgrading anything... |
This error is super misleading. In our case we had defined schema incorrectly. This error occurred when the actual field we were querying for during runtime didnt match up with the schema. Specifically it had to with returning a |
I get this error when I manually update cache via To clarify the use case for maintainers, I have two types: type Project {
id: Int!
name: String!
}
type App {
id: Int!
project: Project!
} First I fetch projects with all fields: query projects {
projects {
id
name
}
} Then I manually update cache via query apps {
apps {
id
project {
id
}
}
} I'll get I hoped I could fix it via I kiiiinda understand why this is the error (to be explicit about data updates/merge) and not a warning but I would really like to have a global option to make it a warning (or just ignore it completely), so my cache writes would go through and I would still be able to define the behaviour (e.g. use existing value if incoming is missing) in I have had this issue for a while now and it's still there in 3.7.0 |
I'm still facing this issue with Given these two types
I use two fragments for the type
The errors appears when the data from the fragment |
+1 on Same scenario as @ragafus |
+1 with 3.7.0 |
How has nobody from Apollo commented on this post. Am I missing something? |
This solved the problem for me. |
i have the same issue here |
Same here. apollo-angular v3.0.0 |
Menaged to fix it somehow. I had this bug in that function
Problem was that i returned only |
I am running into this issue because i have to use an await within "updateQuery". As soon as i set "updateQuery" async the issue pop`s up. |
Solved my issue. Didn't realize it was due to a Subscription lacking the a field the query originally contained. I tweaked the return data on |
I had this error appear using Query: export default gql`
query GetIconQuery($iconId: String!) {
icon(iconId: $iconId) {
url
}
}
`; Mocked data that was erroring: {
request: {
query: GetIconQuery,
variables: {
iconId: icon.id,
},
},
result: {
data: {
url: `icon.svg`,
},
},
} The fix is to change {
request: {
query: GetIconQuery,
variables: {
iconId: icon.id,
},
},
result: {
data: {
icon: {
url: `icon.svg`,
}
},
},
} |
Hi everyone 👋 Can anyone share a runnable reproduction here? With the number of comments—many of which seem to have been resolved by ensuring the data returned matches the shape of the initial request—it's difficult to determine whether there is anything actionable on our end. We have a CodeSandbox and forkable GitHub repo with a |
Hello. I'm getting this error when mocking query results. Here's a CodeSandbox example: |
@alessbell adding every field does solve the issue, but it would be super nice to be able to suppress that warning in tests so nullable fields we don't care about for a test don't need to be specified |
fixed the error by adding
|
Thanks for sharing @hshoja, this fixed the issue for me when testing with React Testing Library and |
We faced a similar issue and upon close investigation, we ended up blaming it on This appears to have been a deliberate change introduced to better support Relay in 2019 in rmosolgo/graphql-ruby#2536 We ended up changing our implementation on the ruby side, which ended up setting And we went from this in our cable stream And there were no more errors and all subscriptions kept on working as expected. If you're running into this error, it may help to consider adjusting the server, rather than waiting for Apollo client to ever change to support this. The issue is really with what restrictions ActionCable places on graphql-ruby for delivering subscriptions. By default, graphql-ruby is conffigured to NOT send a payload for initial subscription, but when it comes to ActionCable channels, it appears unavoidable that something will be sent and in this case it ends up being formatted incorrectly. cc @rmosolgo |
@AndreiRailean I had exactly the same issue but I didn't have to fiddle around with When I left the default class MySubscription < BaseSubscription
argument :whatever_argument, String, required: true
def subscribe(whatever_argument:)
nil
end
end This is now sending Hope that helps people using |
When I do this I get |
Can someone close this issue? It is not about the same thing anymore as the initial issue. |
Hey all 👋 It seems this might have been solved or answered throughout this thread. If there is still an issue, please open a new issue and we'd be happy to take a look. Thanks! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
We've implement subscriptions in our application using the
useSubscription
hook and since upgrading from version 3.3.21 to 3.4.7 we've started to see errors aroundMissing field...
. To be clear we realize these errors have likely always existed, but now they're being surfaced.We see the following error
Missing field 'domainObject' while writing result {}
on initial page load when the subscription is registered. We believe that this happens because the first response from the subscription is an empty object. The subscriptions themselves work fine, this only seems to be an issue when they're initially registered. We'd like to resolve this issue and remove the errors from the console, but have so far been unsuccessful.We tried to update the
fetchPolicy
and found that setting it tono-cache
removed the error, but this stopped the cache from being updated at all, which defeats the purpose.Shown below is a snippet of the code that we've implemented. Some of the subscriptions allow apollo to do the cache updating on its own (
OnObjectUpdated
) while with others (OnObjectDeleted
) we capture the return data and manually make a change to the cache. In both cases we see theMissing field
error. For theOnObjectDeleted
subscription, we added a guard in our callback function because when the subscription is registered we receivedata
as an empty object.We're looking to see if anyone has encountered this and if so how it was resolved.
Thanks!
The text was updated successfully, but these errors were encountered: