2
Good day, i am new to go and i am trying to build a graphql service with go, i did this using the go gqlgen package. Now when install and generate necessary files the initial start up, i can see the default TODO schema and resolver on the docs tab, when i implement or add additional schema to the schema file, i get "Error fetching schema" from the playground
my schema file:
scalar Timestamp
type User {
id: ID!
email: String!
password: String!
otp_code: String!
role: String!
status: String!
isEmailVerified: Boolean!
otp_expire_time: Timestamp!
createdAt: Timestamp!
updatedAt: Timestamp!
deletedAt: Timestamp!
}
input LoginCredential {
email: String!
password: String!
}
input UserSignUpDetail {
email: String!
password: String!
}
type AuthResponse {
access_token: String!
refresh_token: String!
}
type Mutation {
UserLogin(input: LoginCredential!): AuthResponse!
UserSignUp(input: UserSignUpDetail!): User!
}
schema resolver file:
package graph
// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
import (
"context"
"fmt"
"gatewayservice/graph/generated"
"gatewayservice/graph/model"
)
// UserLogin is the resolver for the UserLogin field.
func (r *mutationResolver) UserLogin(ctx context.Context, input model.LoginCredential) (*model.AuthResponse, error) {
panic(fmt.Errorf("not implemented: UserLogin - UserLogin"))
}
// UserSignUp is the resolver for the UserSignUp field.
func (r *mutationResolver) UserSignUp(ctx context.Context, input model.UserSignUpDetail) (*model.User, error) {
panic(fmt.Errorf("not implemented: UserSignUp - UserSignUp"))
}
// Mutation returns generated.MutationResolver implementation.
func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} }
type mutationResolver struct{ *Resolver }
please i need assistance thanks..
1
1 Answer
Reset to default
0
Expect type Mutation
, you should add type Query
(at least one method) to your .graphql file. For example, you can add this to your schema.graphql
:
type Query {
foo(bar: String!): String!
}
After, use gqlgen CLI to generate new Go files that would represent new .graphql schema.
You can share us your
server.go
like ? Where you initialize your generated srv.Oct 24, 2022 at 21:11