So in my use case I have the following schema (simplified to the relevant bits):
type Mutation {
signUp(company: CompanyInput, family: FamilyInput): SignupResult
}
type CompanyInput {
type: OrganizationType
}
type FamilyInput {
type: OrganizationType
}
enum OrganizationType {
COMPANY
FAMILY
}
So my goal is to auto-populate the organizationType based on whether it belongs within CompanyInput or FamilyInput. So that's where getDefaultScalarArgValue comes in.
getDefaultScalarArgValue(parentField, arg, argType) {
/* LOGIC GOES HERE */
}
However, as it executes, when I select the organizationType within CompanyInput which invokes getDefaultScalarArgValue, parentField shows as signUp, arg is organizationType, and argType is OrganizationType. The problem is that you don't know who the immediate parent arg type is (which should be CompanyInput).
So in my use case I have the following schema (simplified to the relevant bits):
So my goal is to auto-populate the
organizationType
based on whether it belongs withinCompanyInput
orFamilyInput
. So that's wheregetDefaultScalarArgValue
comes in.However, as it executes, when I select the
organizationType
within CompanyInput which invokesgetDefaultScalarArgValue
,parentField
shows assignUp
,arg
isorganizationType
, andargType
isOrganizationType
. The problem is that you don't know who the immediate parent arg type is (which should be CompanyInput).My thought is that within this part of
AbstractArgView
class, we need to pass in aparentArg
prop. https://github.com/OneGraph/graphiql-explorer/blob/69da97c4a3de988a405caa2707ec9a4133e4b614/src/Explorer.js#L790-L812And this propagate that to
getDefaultScalarArgValue
, which would change its signature however:I'm wary of making signature changes. But when I pass in the parentArg, I can see that the
organizationType
belongs toCompanyInput
orFamilyInput
.