From 22d8ef540ea35ccbab955cabd6281e5b130af508 Mon Sep 17 00:00:00 2001 From: Haily Nguyen Date: Thu, 12 Sep 2024 12:50:45 -0700 Subject: [PATCH] make rewrite default for single-file mode and update ALL generate test cases --- _examples/type-system-extension/gqlgen.yml | 3 - codegen/testserver/followschema/resolver.go | 213 +++++++++--------- .../testserver/nullabledirectives/gqlgen.yml | 5 +- codegen/testserver/singlefile/resolver.go | 213 +++++++++--------- integration/server/gqlgen.yml | 3 - plugin/resolvergen/resolver.go | 26 ++- plugin/resolvergen/resolver.gotpl | 2 + .../testdata/singlefile/out/resolver.go | 7 +- 8 files changed, 241 insertions(+), 231 deletions(-) diff --git a/_examples/type-system-extension/gqlgen.yml b/_examples/type-system-extension/gqlgen.yml index bc7a31dba0..eba540c1f8 100644 --- a/_examples/type-system-extension/gqlgen.yml +++ b/_examples/type-system-extension/gqlgen.yml @@ -10,6 +10,3 @@ exec: filename: generated.go model: filename: models_gen.go -resolver: - filename: resolver.go - type: Resolver diff --git a/codegen/testserver/followschema/resolver.go b/codegen/testserver/followschema/resolver.go index 94bd8816ca..ce5ce96966 100644 --- a/codegen/testserver/followschema/resolver.go +++ b/codegen/testserver/followschema/resolver.go @@ -1,9 +1,10 @@ package followschema -// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. +// THIS CODE WILL BE UPDATED WITH SCHEMA CHANGES. PREVIOUS IMPLEMENTATION FOR SCHEMA CHANGES WILL BE KEPT IN THE COMMENT SECTION. IMPLEMENTATION FOR UNCHANGED SCHEMA WILL BE KEPT. import ( "context" + "fmt" introspection1 "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename" @@ -14,527 +15,527 @@ type Resolver struct{} // ID is the resolver for the id field. func (r *backedByInterfaceResolver) ID(ctx context.Context, obj BackedByInterface) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ID - id")) } // Values is the resolver for the values field. func (r *deferModelResolver) Values(ctx context.Context, obj *DeferModel) ([]string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Values - values")) } // A is the resolver for the a field. func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: A - a")) } // B is the resolver for the b field. func (r *errorsResolver) B(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: B - b")) } // C is the resolver for the c field. func (r *errorsResolver) C(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: C - c")) } // D is the resolver for the d field. func (r *errorsResolver) D(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: D - d")) } // E is the resolver for the e field. func (r *errorsResolver) E(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: E - e")) } // Field is the resolver for the field field. func (r *forcedResolverResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Field - field")) } // ResolverField is the resolver for the resolverField field. func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ResolverField - resolverField")) } // DefaultInput is the resolver for the defaultInput field. func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DefaultInput - defaultInput")) } // OverrideValueViaInput is the resolver for the overrideValueViaInput field. func (r *mutationResolver) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: OverrideValueViaInput - overrideValueViaInput")) } // UpdateSomething is the resolver for the updateSomething field. func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: UpdateSomething - updateSomething")) } // UpdatePtrToPtr is the resolver for the updatePtrToPtr field. func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: UpdatePtrToPtr - updatePtrToPtr")) } // OldFoo is the resolver for the oldFoo field. func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: OldFoo - oldFoo")) } // FieldScalarMarshal is the resolver for the fieldScalarMarshal field. func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: FieldScalarMarshal - fieldScalarMarshal")) } // ArgUnmarshal is the resolver for the argUnmarshal field. func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ArgUnmarshal - argUnmarshal")) } // Friends is the resolver for the friends field. func (r *petResolver) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Friends - friends")) } // Value is the resolver for the value field. func (r *primitiveResolver) Value(ctx context.Context, obj *Primitive) (int, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Value - value")) } // Value is the resolver for the value field. func (r *primitiveStringResolver) Value(ctx context.Context, obj *PrimitiveString) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Value - value")) } // Len is the resolver for the len field. func (r *primitiveStringResolver) Len(ctx context.Context, obj *PrimitiveString) (int, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Len - len")) } // InvalidIdentifier is the resolver for the invalidIdentifier field. func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InvalidIdentifier - invalidIdentifier")) } // Collision is the resolver for the collision field. func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Collision - collision")) } // MapInput is the resolver for the mapInput field. func (r *queryResolver) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: MapInput - mapInput")) } // Recursive is the resolver for the recursive field. func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Recursive - recursive")) } // NestedInputs is the resolver for the nestedInputs field. func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NestedInputs - nestedInputs")) } // NestedOutputs is the resolver for the nestedOutputs field. func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NestedOutputs - nestedOutputs")) } // ModelMethods is the resolver for the modelMethods field. func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ModelMethods - modelMethods")) } // User is the resolver for the user field. func (r *queryResolver) User(ctx context.Context, id int) (*User, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: User - user")) } // NullableArg is the resolver for the nullableArg field. func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NullableArg - nullableArg")) } // InputSlice is the resolver for the inputSlice field. func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InputSlice - inputSlice")) } // InputNullableSlice is the resolver for the inputNullableSlice field. func (r *queryResolver) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InputNullableSlice - inputNullableSlice")) } // InputOmittable is the resolver for the inputOmittable field. func (r *queryResolver) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InputOmittable - inputOmittable")) } // ShapeUnion is the resolver for the shapeUnion field. func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ShapeUnion - shapeUnion")) } // Autobind is the resolver for the autobind field. func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Autobind - autobind")) } // DeprecatedField is the resolver for the deprecatedField field. func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DeprecatedField - deprecatedField")) } // Overlapping is the resolver for the overlapping field. func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Overlapping - overlapping")) } // DefaultParameters is the resolver for the defaultParameters field. func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DefaultParameters - defaultParameters")) } // DeferCase1 is the resolver for the deferCase1 field. func (r *queryResolver) DeferCase1(ctx context.Context) (*DeferModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DeferCase1 - deferCase1")) } // DeferCase2 is the resolver for the deferCase2 field. func (r *queryResolver) DeferCase2(ctx context.Context) ([]*DeferModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DeferCase2 - deferCase2")) } // DirectiveArg is the resolver for the directiveArg field. func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveArg - directiveArg")) } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveNullableArg - directiveNullableArg")) } // DirectiveSingleNullableArg is the resolver for the directiveSingleNullableArg field. func (r *queryResolver) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveSingleNullableArg - directiveSingleNullableArg")) } // DirectiveInputNullable is the resolver for the directiveInputNullable field. func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveInputNullable - directiveInputNullable")) } // DirectiveInput is the resolver for the directiveInput field. func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveInput - directiveInput")) } // DirectiveInputType is the resolver for the directiveInputType field. func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveInputType - directiveInputType")) } // DirectiveObject is the resolver for the directiveObject field. func (r *queryResolver) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveObject - directiveObject")) } // DirectiveObjectWithCustomGoModel is the resolver for the directiveObjectWithCustomGoModel field. func (r *queryResolver) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveObjectWithCustomGoModel - directiveObjectWithCustomGoModel")) } // DirectiveFieldDef is the resolver for the directiveFieldDef field. func (r *queryResolver) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveFieldDef - directiveFieldDef")) } // DirectiveField is the resolver for the directiveField field. func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveField - directiveField")) } // DirectiveDouble is the resolver for the directiveDouble field. func (r *queryResolver) DirectiveDouble(ctx context.Context) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveDouble - directiveDouble")) } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveUnimplemented - directiveUnimplemented")) } // DirectiveConcurrent is the resolver for the directiveConcurrent field. func (r *queryResolver) DirectiveConcurrent(ctx context.Context) ([]*ObjectDirectivesConcurrent, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveConcurrent - directiveConcurrent")) } // EmbeddedCase1 is the resolver for the embeddedCase1 field. func (r *queryResolver) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EmbeddedCase1 - embeddedCase1")) } // EmbeddedCase2 is the resolver for the embeddedCase2 field. func (r *queryResolver) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EmbeddedCase2 - embeddedCase2")) } // EmbeddedCase3 is the resolver for the embeddedCase3 field. func (r *queryResolver) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EmbeddedCase3 - embeddedCase3")) } // EnumInInput is the resolver for the enumInInput field. func (r *queryResolver) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EnumInInput - enumInInput")) } // Shapes is the resolver for the shapes field. func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Shapes - shapes")) } // NoShape is the resolver for the noShape field. func (r *queryResolver) NoShape(ctx context.Context) (Shape, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NoShape - noShape")) } // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context) (Node, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Node - node")) } // NoShapeTypedNil is the resolver for the noShapeTypedNil field. func (r *queryResolver) NoShapeTypedNil(ctx context.Context) (Shape, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NoShapeTypedNil - noShapeTypedNil")) } // Animal is the resolver for the animal field. func (r *queryResolver) Animal(ctx context.Context) (Animal, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Animal - animal")) } // NotAnInterface is the resolver for the notAnInterface field. func (r *queryResolver) NotAnInterface(ctx context.Context) (BackedByInterface, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NotAnInterface - notAnInterface")) } // Dog is the resolver for the dog field. func (r *queryResolver) Dog(ctx context.Context) (*Dog, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Dog - dog")) } // Issue896a is the resolver for the issue896a field. func (r *queryResolver) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Issue896a - issue896a")) } // MapStringInterface is the resolver for the mapStringInterface field. func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: MapStringInterface - mapStringInterface")) } // MapNestedStringInterface is the resolver for the mapNestedStringInterface field. func (r *queryResolver) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: MapNestedStringInterface - mapNestedStringInterface")) } // ErrorBubble is the resolver for the errorBubble field. func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorBubble - errorBubble")) } // ErrorBubbleList is the resolver for the errorBubbleList field. func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorBubbleList - errorBubbleList")) } // ErrorList is the resolver for the errorList field. func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorList - errorList")) } // Errors is the resolver for the errors field. func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Errors - errors")) } // Valid is the resolver for the valid field. func (r *queryResolver) Valid(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Valid - valid")) } // Invalid is the resolver for the invalid field. func (r *queryResolver) Invalid(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Invalid - invalid")) } // Panics is the resolver for the panics field. func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Panics - panics")) } // PrimitiveObject is the resolver for the primitiveObject field. func (r *queryResolver) PrimitiveObject(ctx context.Context) ([]Primitive, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PrimitiveObject - primitiveObject")) } // PrimitiveStringObject is the resolver for the primitiveStringObject field. func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PrimitiveStringObject - primitiveStringObject")) } // PtrToAnyContainer is the resolver for the ptrToAnyContainer field. func (r *queryResolver) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PtrToAnyContainer - ptrToAnyContainer")) } // PtrToSliceContainer is the resolver for the ptrToSliceContainer field. func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PtrToSliceContainer - ptrToSliceContainer")) } // Infinity is the resolver for the infinity field. func (r *queryResolver) Infinity(ctx context.Context) (float64, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Infinity - infinity")) } // StringFromContextInterface is the resolver for the stringFromContextInterface field. func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: StringFromContextInterface - stringFromContextInterface")) } // StringFromContextFunction is the resolver for the stringFromContextFunction field. func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: StringFromContextFunction - stringFromContextFunction")) } // DefaultScalar is the resolver for the defaultScalar field. func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DefaultScalar - defaultScalar")) } // Slices is the resolver for the slices field. func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Slices - slices")) } // ScalarSlice is the resolver for the scalarSlice field. func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ScalarSlice - scalarSlice")) } // Fallback is the resolver for the fallback field. func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Fallback - fallback")) } // OptionalUnion is the resolver for the optionalUnion field. func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: OptionalUnion - optionalUnion")) } // VOkCaseValue is the resolver for the vOkCaseValue field. func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: VOkCaseValue - vOkCaseValue")) } // VOkCaseNil is the resolver for the vOkCaseNil field. func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: VOkCaseNil - vOkCaseNil")) } // ValidType is the resolver for the validType field. func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ValidType - validType")) } // VariadicModel is the resolver for the variadicModel field. func (r *queryResolver) VariadicModel(ctx context.Context) (*VariadicModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: VariadicModel - variadicModel")) } // WrappedStruct is the resolver for the wrappedStruct field. func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedStruct - wrappedStruct")) } // WrappedScalar is the resolver for the wrappedScalar field. func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedScalar - wrappedScalar")) } // WrappedMap is the resolver for the wrappedMap field. func (r *queryResolver) WrappedMap(ctx context.Context) (WrappedMap, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedMap - wrappedMap")) } // WrappedSlice is the resolver for the wrappedSlice field. func (r *queryResolver) WrappedSlice(ctx context.Context) (WrappedSlice, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedSlice - wrappedSlice")) } // Updated is the resolver for the updated field. func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Updated - updated")) } // InitPayload is the resolver for the initPayload field. func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InitPayload - initPayload")) } // DirectiveArg is the resolver for the directiveArg field. func (r *subscriptionResolver) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveArg - directiveArg")) } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *subscriptionResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveNullableArg - directiveNullableArg")) } // DirectiveDouble is the resolver for the directiveDouble field. func (r *subscriptionResolver) DirectiveDouble(ctx context.Context) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveDouble - directiveDouble")) } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *subscriptionResolver) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveUnimplemented - directiveUnimplemented")) } // Issue896b is the resolver for the issue896b field. func (r *subscriptionResolver) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Issue896b - issue896b")) } // ErrorRequired is the resolver for the errorRequired field. func (r *subscriptionResolver) ErrorRequired(ctx context.Context) (<-chan *Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorRequired - errorRequired")) } // Friends is the resolver for the friends field. func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Friends - friends")) } // Pets is the resolver for the pets field. func (r *userResolver) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Pets - pets")) } // Get is the resolver for the get field. func (r *wrappedMapResolver) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Get - get")) } // Get is the resolver for the get field. func (r *wrappedSliceResolver) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Get - get")) } // BackedByInterface returns BackedByInterfaceResolver implementation. diff --git a/codegen/testserver/nullabledirectives/gqlgen.yml b/codegen/testserver/nullabledirectives/gqlgen.yml index 657e9d0412..0090b822b2 100644 --- a/codegen/testserver/nullabledirectives/gqlgen.yml +++ b/codegen/testserver/nullabledirectives/gqlgen.yml @@ -8,9 +8,6 @@ exec: model: filename: generated/models/models-gen.go package: models -resolver: - filename: generated/resolvers/resolver.go - package: resolver - type: Resolver + call_argument_directives_with_null: true diff --git a/codegen/testserver/singlefile/resolver.go b/codegen/testserver/singlefile/resolver.go index 89a37561ab..4a6263f97b 100644 --- a/codegen/testserver/singlefile/resolver.go +++ b/codegen/testserver/singlefile/resolver.go @@ -1,9 +1,10 @@ package singlefile -// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. +// THIS CODE WILL BE UPDATED WITH SCHEMA CHANGES. PREVIOUS IMPLEMENTATION FOR SCHEMA CHANGES WILL BE KEPT IN THE COMMENT SECTION. IMPLEMENTATION FOR UNCHANGED SCHEMA WILL BE KEPT. import ( "context" + "fmt" introspection1 "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename" @@ -14,527 +15,527 @@ type Resolver struct{} // ID is the resolver for the id field. func (r *backedByInterfaceResolver) ID(ctx context.Context, obj BackedByInterface) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ID - id")) } // Values is the resolver for the values field. func (r *deferModelResolver) Values(ctx context.Context, obj *DeferModel) ([]string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Values - values")) } // A is the resolver for the a field. func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: A - a")) } // B is the resolver for the b field. func (r *errorsResolver) B(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: B - b")) } // C is the resolver for the c field. func (r *errorsResolver) C(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: C - c")) } // D is the resolver for the d field. func (r *errorsResolver) D(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: D - d")) } // E is the resolver for the e field. func (r *errorsResolver) E(ctx context.Context, obj *Errors) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: E - e")) } // Field is the resolver for the field field. func (r *forcedResolverResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Field - field")) } // ResolverField is the resolver for the resolverField field. func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ResolverField - resolverField")) } // DefaultInput is the resolver for the defaultInput field. func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DefaultInput - defaultInput")) } // OverrideValueViaInput is the resolver for the overrideValueViaInput field. func (r *mutationResolver) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: OverrideValueViaInput - overrideValueViaInput")) } // UpdateSomething is the resolver for the updateSomething field. func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: UpdateSomething - updateSomething")) } // UpdatePtrToPtr is the resolver for the updatePtrToPtr field. func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: UpdatePtrToPtr - updatePtrToPtr")) } // OldFoo is the resolver for the oldFoo field. func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: OldFoo - oldFoo")) } // FieldScalarMarshal is the resolver for the fieldScalarMarshal field. func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: FieldScalarMarshal - fieldScalarMarshal")) } // ArgUnmarshal is the resolver for the argUnmarshal field. func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ArgUnmarshal - argUnmarshal")) } // Friends is the resolver for the friends field. func (r *petResolver) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Friends - friends")) } // Value is the resolver for the value field. func (r *primitiveResolver) Value(ctx context.Context, obj *Primitive) (int, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Value - value")) } // Value is the resolver for the value field. func (r *primitiveStringResolver) Value(ctx context.Context, obj *PrimitiveString) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Value - value")) } // Len is the resolver for the len field. func (r *primitiveStringResolver) Len(ctx context.Context, obj *PrimitiveString) (int, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Len - len")) } // InvalidIdentifier is the resolver for the invalidIdentifier field. func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InvalidIdentifier - invalidIdentifier")) } // Collision is the resolver for the collision field. func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Collision - collision")) } // MapInput is the resolver for the mapInput field. func (r *queryResolver) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: MapInput - mapInput")) } // Recursive is the resolver for the recursive field. func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Recursive - recursive")) } // NestedInputs is the resolver for the nestedInputs field. func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NestedInputs - nestedInputs")) } // NestedOutputs is the resolver for the nestedOutputs field. func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NestedOutputs - nestedOutputs")) } // ModelMethods is the resolver for the modelMethods field. func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ModelMethods - modelMethods")) } // User is the resolver for the user field. func (r *queryResolver) User(ctx context.Context, id int) (*User, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: User - user")) } // NullableArg is the resolver for the nullableArg field. func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NullableArg - nullableArg")) } // InputSlice is the resolver for the inputSlice field. func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InputSlice - inputSlice")) } // InputNullableSlice is the resolver for the inputNullableSlice field. func (r *queryResolver) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InputNullableSlice - inputNullableSlice")) } // InputOmittable is the resolver for the inputOmittable field. func (r *queryResolver) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InputOmittable - inputOmittable")) } // ShapeUnion is the resolver for the shapeUnion field. func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ShapeUnion - shapeUnion")) } // Autobind is the resolver for the autobind field. func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Autobind - autobind")) } // DeprecatedField is the resolver for the deprecatedField field. func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DeprecatedField - deprecatedField")) } // Overlapping is the resolver for the overlapping field. func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Overlapping - overlapping")) } // DefaultParameters is the resolver for the defaultParameters field. func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DefaultParameters - defaultParameters")) } // DeferCase1 is the resolver for the deferCase1 field. func (r *queryResolver) DeferCase1(ctx context.Context) (*DeferModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DeferCase1 - deferCase1")) } // DeferCase2 is the resolver for the deferCase2 field. func (r *queryResolver) DeferCase2(ctx context.Context) ([]*DeferModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DeferCase2 - deferCase2")) } // DirectiveArg is the resolver for the directiveArg field. func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveArg - directiveArg")) } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveNullableArg - directiveNullableArg")) } // DirectiveSingleNullableArg is the resolver for the directiveSingleNullableArg field. func (r *queryResolver) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveSingleNullableArg - directiveSingleNullableArg")) } // DirectiveInputNullable is the resolver for the directiveInputNullable field. func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveInputNullable - directiveInputNullable")) } // DirectiveInput is the resolver for the directiveInput field. func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveInput - directiveInput")) } // DirectiveInputType is the resolver for the directiveInputType field. func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveInputType - directiveInputType")) } // DirectiveObject is the resolver for the directiveObject field. func (r *queryResolver) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveObject - directiveObject")) } // DirectiveObjectWithCustomGoModel is the resolver for the directiveObjectWithCustomGoModel field. func (r *queryResolver) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveObjectWithCustomGoModel - directiveObjectWithCustomGoModel")) } // DirectiveFieldDef is the resolver for the directiveFieldDef field. func (r *queryResolver) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveFieldDef - directiveFieldDef")) } // DirectiveField is the resolver for the directiveField field. func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveField - directiveField")) } // DirectiveDouble is the resolver for the directiveDouble field. func (r *queryResolver) DirectiveDouble(ctx context.Context) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveDouble - directiveDouble")) } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveUnimplemented - directiveUnimplemented")) } // DirectiveConcurrent is the resolver for the directiveConcurrent field. func (r *queryResolver) DirectiveConcurrent(ctx context.Context) ([]*ObjectDirectivesConcurrent, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveConcurrent - directiveConcurrent")) } // EmbeddedCase1 is the resolver for the embeddedCase1 field. func (r *queryResolver) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EmbeddedCase1 - embeddedCase1")) } // EmbeddedCase2 is the resolver for the embeddedCase2 field. func (r *queryResolver) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EmbeddedCase2 - embeddedCase2")) } // EmbeddedCase3 is the resolver for the embeddedCase3 field. func (r *queryResolver) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EmbeddedCase3 - embeddedCase3")) } // EnumInInput is the resolver for the enumInInput field. func (r *queryResolver) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: EnumInInput - enumInInput")) } // Shapes is the resolver for the shapes field. func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Shapes - shapes")) } // NoShape is the resolver for the noShape field. func (r *queryResolver) NoShape(ctx context.Context) (Shape, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NoShape - noShape")) } // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context) (Node, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Node - node")) } // NoShapeTypedNil is the resolver for the noShapeTypedNil field. func (r *queryResolver) NoShapeTypedNil(ctx context.Context) (Shape, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NoShapeTypedNil - noShapeTypedNil")) } // Animal is the resolver for the animal field. func (r *queryResolver) Animal(ctx context.Context) (Animal, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Animal - animal")) } // NotAnInterface is the resolver for the notAnInterface field. func (r *queryResolver) NotAnInterface(ctx context.Context) (BackedByInterface, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: NotAnInterface - notAnInterface")) } // Dog is the resolver for the dog field. func (r *queryResolver) Dog(ctx context.Context) (*Dog, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Dog - dog")) } // Issue896a is the resolver for the issue896a field. func (r *queryResolver) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Issue896a - issue896a")) } // MapStringInterface is the resolver for the mapStringInterface field. func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: MapStringInterface - mapStringInterface")) } // MapNestedStringInterface is the resolver for the mapNestedStringInterface field. func (r *queryResolver) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: MapNestedStringInterface - mapNestedStringInterface")) } // ErrorBubble is the resolver for the errorBubble field. func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorBubble - errorBubble")) } // ErrorBubbleList is the resolver for the errorBubbleList field. func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorBubbleList - errorBubbleList")) } // ErrorList is the resolver for the errorList field. func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorList - errorList")) } // Errors is the resolver for the errors field. func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Errors - errors")) } // Valid is the resolver for the valid field. func (r *queryResolver) Valid(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Valid - valid")) } // Invalid is the resolver for the invalid field. func (r *queryResolver) Invalid(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Invalid - invalid")) } // Panics is the resolver for the panics field. func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Panics - panics")) } // PrimitiveObject is the resolver for the primitiveObject field. func (r *queryResolver) PrimitiveObject(ctx context.Context) ([]Primitive, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PrimitiveObject - primitiveObject")) } // PrimitiveStringObject is the resolver for the primitiveStringObject field. func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PrimitiveStringObject - primitiveStringObject")) } // PtrToAnyContainer is the resolver for the ptrToAnyContainer field. func (r *queryResolver) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PtrToAnyContainer - ptrToAnyContainer")) } // PtrToSliceContainer is the resolver for the ptrToSliceContainer field. func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: PtrToSliceContainer - ptrToSliceContainer")) } // Infinity is the resolver for the infinity field. func (r *queryResolver) Infinity(ctx context.Context) (float64, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Infinity - infinity")) } // StringFromContextInterface is the resolver for the stringFromContextInterface field. func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: StringFromContextInterface - stringFromContextInterface")) } // StringFromContextFunction is the resolver for the stringFromContextFunction field. func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: StringFromContextFunction - stringFromContextFunction")) } // DefaultScalar is the resolver for the defaultScalar field. func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DefaultScalar - defaultScalar")) } // Slices is the resolver for the slices field. func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Slices - slices")) } // ScalarSlice is the resolver for the scalarSlice field. func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ScalarSlice - scalarSlice")) } // Fallback is the resolver for the fallback field. func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Fallback - fallback")) } // OptionalUnion is the resolver for the optionalUnion field. func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: OptionalUnion - optionalUnion")) } // VOkCaseValue is the resolver for the vOkCaseValue field. func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: VOkCaseValue - vOkCaseValue")) } // VOkCaseNil is the resolver for the vOkCaseNil field. func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: VOkCaseNil - vOkCaseNil")) } // ValidType is the resolver for the validType field. func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ValidType - validType")) } // VariadicModel is the resolver for the variadicModel field. func (r *queryResolver) VariadicModel(ctx context.Context) (*VariadicModel, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: VariadicModel - variadicModel")) } // WrappedStruct is the resolver for the wrappedStruct field. func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedStruct - wrappedStruct")) } // WrappedScalar is the resolver for the wrappedScalar field. func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedScalar - wrappedScalar")) } // WrappedMap is the resolver for the wrappedMap field. func (r *queryResolver) WrappedMap(ctx context.Context) (WrappedMap, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedMap - wrappedMap")) } // WrappedSlice is the resolver for the wrappedSlice field. func (r *queryResolver) WrappedSlice(ctx context.Context) (WrappedSlice, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: WrappedSlice - wrappedSlice")) } // Updated is the resolver for the updated field. func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Updated - updated")) } // InitPayload is the resolver for the initPayload field. func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: InitPayload - initPayload")) } // DirectiveArg is the resolver for the directiveArg field. func (r *subscriptionResolver) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveArg - directiveArg")) } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *subscriptionResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveNullableArg - directiveNullableArg")) } // DirectiveDouble is the resolver for the directiveDouble field. func (r *subscriptionResolver) DirectiveDouble(ctx context.Context) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveDouble - directiveDouble")) } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *subscriptionResolver) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: DirectiveUnimplemented - directiveUnimplemented")) } // Issue896b is the resolver for the issue896b field. func (r *subscriptionResolver) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Issue896b - issue896b")) } // ErrorRequired is the resolver for the errorRequired field. func (r *subscriptionResolver) ErrorRequired(ctx context.Context) (<-chan *Error, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: ErrorRequired - errorRequired")) } // Friends is the resolver for the friends field. func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Friends - friends")) } // Pets is the resolver for the pets field. func (r *userResolver) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Pets - pets")) } // Get is the resolver for the get field. func (r *wrappedMapResolver) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Get - get")) } // Get is the resolver for the get field. func (r *wrappedSliceResolver) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Get - get")) } // BackedByInterface returns BackedByInterfaceResolver implementation. diff --git a/integration/server/gqlgen.yml b/integration/server/gqlgen.yml index 427490c7ef..9195079be1 100644 --- a/integration/server/gqlgen.yml +++ b/integration/server/gqlgen.yml @@ -5,9 +5,6 @@ exec: filename: generated.go model: filename: models-go/generated.go -resolver: - filename: resolver.go - type: Resolver struct_tag: json diff --git a/plugin/resolvergen/resolver.go b/plugin/resolvergen/resolver.go index 38138d5201..c50b476366 100644 --- a/plugin/resolvergen/resolver.go +++ b/plugin/resolvergen/resolver.go @@ -53,26 +53,40 @@ func (m *Plugin) GenerateCode(data *codegen.Data) error { func (m *Plugin) generateSingleFile(data *codegen.Data) error { file := File{} - - if _, err := os.Stat(data.Config.Resolver.Filename); err == nil { - // file already exists and we do not support updating resolvers with layout = single so just return - return nil + rewriter, err := rewrite.New(data.Config.Resolver.Dir()) + if err != nil { + return err } for _, o := range data.Objects { if o.HasResolvers() { + caser := cases.Title(language.English, cases.NoLower) + rewriter.MarkStructCopied(templates.LcFirst(o.Name) + templates.UcFirst(data.Config.Resolver.Type)) + rewriter.GetMethodBody(data.Config.Resolver.Type, caser.String(o.Name)) + file.Objects = append(file.Objects, o) } + for _, f := range o.Fields { if !f.IsResolver { continue } - resolver := Resolver{o, f, nil, "", `panic("not implemented")`, nil} + structName := templates.LcFirst(o.Name) + templates.UcFirst(data.Config.Resolver.Type) + comment := strings.TrimSpace(strings.TrimLeft(rewriter.GetMethodComment(structName, f.GoFieldName), `\`)) + implementation := strings.TrimSpace(rewriter.GetMethodBody(structName, f.GoFieldName)) + + resolver := Resolver{o, f, rewriter.GetPrevDecl(structName, f.GoFieldName), comment, implementation, nil} file.Resolvers = append(file.Resolvers, &resolver) } } + if _, err := os.Stat(data.Config.Resolver.Filename); err == nil { + file.name = data.Config.Resolver.Filename + file.imports = rewriter.ExistingImports(file.name) + file.RemainingSource = rewriter.RemainingSource(file.name) + } + resolverBuild := &ResolverBuild{ File: &file, PackageName: data.Config.Resolver.Package, @@ -88,7 +102,7 @@ func (m *Plugin) generateSingleFile(data *codegen.Data) error { return templates.Render(templates.Options{ PackageName: data.Config.Resolver.Package, - FileNotice: `// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.`, + FileNotice: `// THIS CODE WILL BE UPDATED WITH SCHEMA CHANGES. PREVIOUS IMPLEMENTATION FOR SCHEMA CHANGES WILL BE KEPT IN THE COMMENT SECTION. IMPLEMENTATION FOR UNCHANGED SCHEMA WILL BE KEPT.`, Filename: data.Config.Resolver.Filename, Data: resolverBuild, Packages: data.Config.Packages, diff --git a/plugin/resolvergen/resolver.gotpl b/plugin/resolvergen/resolver.gotpl index c25bd1d562..ad6c108581 100644 --- a/plugin/resolvergen/resolver.gotpl +++ b/plugin/resolvergen/resolver.gotpl @@ -48,5 +48,7 @@ // - When renaming or deleting a resolver the old code will be put in here. You can safely delete // it when you're done. // - You have helper methods in this file. Move them out to keep these resolver files clean. + /* {{ .RemainingSource }} + */ {{ end }} diff --git a/plugin/resolvergen/testdata/singlefile/out/resolver.go b/plugin/resolvergen/testdata/singlefile/out/resolver.go index 844b077c4a..614c66cf18 100644 --- a/plugin/resolvergen/testdata/singlefile/out/resolver.go +++ b/plugin/resolvergen/testdata/singlefile/out/resolver.go @@ -1,21 +1,22 @@ package customresolver -// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. +// THIS CODE WILL BE UPDATED WITH SCHEMA CHANGES. PREVIOUS IMPLEMENTATION FOR SCHEMA CHANGES WILL BE KEPT IN THE COMMENT SECTION. IMPLEMENTATION FOR UNCHANGED SCHEMA WILL BE KEPT. import ( "context" + "fmt" ) type CustomResolverType struct{} // Resolver is the resolver for the resolver field. func (r *queryCustomResolverType) Resolver(ctx context.Context) (*Resolver, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Resolver - resolver")) } // Name is the resolver for the name field. func (r *resolverCustomResolverType) Name(ctx context.Context, obj *Resolver) (string, error) { - panic("not implemented") + panic(fmt.Errorf("not implemented: Name - name")) } // Query returns QueryResolver implementation.