-
Yet another question. type NameOfServiceMutations {
createSomeThing: String!
integrate(input: NameOfServiceInput!): NameOfServiceIntegrationPayload!
}
type IntegrationMutations {
nameOfService: NameOfServiceMutations!
}
type Mutation {
"Collects all possible mutations on company"
company: CompanyMutations!
"Collects all possible mutations on integrations"
integration: IntegrationMutations!
"Collects all possible mutations on onboarding"
onboarding: OnboardingMutations!
} With the usage like that mutation NameOfServiceButton_Integrate($someString: String!, $metadata: JSON!) {
integration {
nameOfService {
integrate(input: { metadata: $metadata, someString: $someString }) {
...NameOfServiceButton_NameOfServiceIntegraionPayload
}
}
}
} So this pattern is some sort of namespacing for particular entities/resources if you wish. Works both for Queries and even better for Mutations as there is no longer mutation {
entityName {
create(input: {...}) {
...
}
} The Problem tho, is that NameOfServiceMutations: {
integrate: (result, args, cache, info) => {}
} But only from the root Mutation type like Mutation: {
integraton: (result, args, cache, info) => {}
} And then you should branch based on How to work around this one? Or maybe it can be added as a feature? Or maybe there are some helper functions that can extract such from |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
This is a conscious limitation. GraphQL actively discourages you from "name spacing" mutations in result types. There are several reasons for that but two are relevant here:
The latter is relevant because we can feasibly allow updaters to be written for any field. But we don't and actively discourage this because that means you could write updaters for any field including just data. I'd suggest, and I'm pleading here 😅, please don't do this. This is one of these things that look right-ish if you haven't dealt with it before, is a case where you're trying to be more clever than the GraphQL spec, and leads to more issues down the line. I'm saying this because, again, we could support this, but don't right now for a reason. Here are some follow up links on the topic while I'm at it ❤️ |
Beta Was this translation helpful? Give feedback.
-
Leaving a note here, See comment: #1244 (reply in thread) It's now possible to write updaters for any type & field combination, and not just This is mainly meant though to catch "invisible updates" that are necessary when writing This is often an optimisation, or when integration this into schema design would actually make things more convoluted. In some cases, it's infeasible to add relations infinitely to query selection sets, to make sure that maybe a future Graphcache query can read from the cache. |
Beta Was this translation helpful? Give feedback.
This is a conscious limitation. GraphQL actively discourages you from "name spacing" mutations in result types. There are several reasons for that but two are relevant here:
The latter is relevant because we can feasibly allow updaters to be written for any field. But we …