Documentation ¶
Index ¶
- Variables
- type GraphqlField
- func (*GraphqlField) Descriptor() ([]byte, []int)deprecated
- func (x *GraphqlField) GetDefault() string
- func (x *GraphqlField) GetName() string
- func (x *GraphqlField) GetOmit() bool
- func (x *GraphqlField) GetRequired() bool
- func (x *GraphqlField) GetResolver() string
- func (*GraphqlField) ProtoMessage()
- func (x *GraphqlField) ProtoReflect() protoreflect.Message
- func (x *GraphqlField) Reset()
- func (x *GraphqlField) String() string
- type GraphqlRequest
- func (*GraphqlRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GraphqlRequest) GetName() string
- func (x *GraphqlRequest) GetPlucks() []string
- func (*GraphqlRequest) ProtoMessage()
- func (x *GraphqlRequest) ProtoReflect() protoreflect.Message
- func (x *GraphqlRequest) Reset()
- func (x *GraphqlRequest) String() string
- type GraphqlResponse
- func (*GraphqlResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GraphqlResponse) GetPluck() string
- func (x *GraphqlResponse) GetRequired() bool
- func (*GraphqlResponse) ProtoMessage()
- func (x *GraphqlResponse) ProtoReflect() protoreflect.Message
- func (x *GraphqlResponse) Reset()
- func (x *GraphqlResponse) String() string
- type GraphqlSchema
- func (*GraphqlSchema) Descriptor() ([]byte, []int)deprecated
- func (x *GraphqlSchema) GetName() string
- func (x *GraphqlSchema) GetRequest() *GraphqlRequest
- func (x *GraphqlSchema) GetResponse() *GraphqlResponse
- func (x *GraphqlSchema) GetType() GraphqlType
- func (*GraphqlSchema) ProtoMessage()
- func (x *GraphqlSchema) ProtoReflect() protoreflect.Message
- func (x *GraphqlSchema) Reset()
- func (x *GraphqlSchema) String() string
- type GraphqlService
- func (*GraphqlService) Descriptor() ([]byte, []int)deprecated
- func (x *GraphqlService) GetHost() string
- func (x *GraphqlService) GetInsecure() bool
- func (*GraphqlService) ProtoMessage()
- func (x *GraphqlService) ProtoReflect() protoreflect.Message
- func (x *GraphqlService) Reset()
- func (x *GraphqlService) String() string
- type GraphqlType
- func (GraphqlType) Descriptor() protoreflect.EnumDescriptor
- func (x GraphqlType) Enum() *GraphqlType
- func (GraphqlType) EnumDescriptor() ([]byte, []int)deprecated
- func (x GraphqlType) Number() protoreflect.EnumNumber
- func (x GraphqlType) String() string
- func (GraphqlType) Type() protoreflect.EnumType
Constants ¶
This section is empty.
Variables ¶
var ( GraphqlType_name = map[int32]string{ 0: "QUERY", 1: "MUTATION", 2: "RESOLVER", } GraphqlType_value = map[string]int32{ "QUERY": 0, "MUTATION": 1, "RESOLVER": 2, } )
Enum value maps for GraphqlType.
var (
// optional graphql.GraphqlField field = 1079;
E_Field = &file_graphql_proto_extTypes[1]
)
Extension fields to descriptorpb.FieldOptions.
var (
// optional graphql.GraphqlSchema schema = 1079;
E_Schema = &file_graphql_proto_extTypes[2]
)
Extension fields to descriptorpb.MethodOptions.
var (
// optional graphql.GraphqlService service = 1079;
E_Service = &file_graphql_proto_extTypes[0]
)
Extension fields to descriptorpb.ServiceOptions.
var File_graphql_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type GraphqlField ¶
type GraphqlField struct { // If true, this field is required. Required bool `protobuf:"varint,1,opt,name=required,proto3" json:"required,omitempty"` // Use as other field name (not recommend) Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Define default value on input. Default string `protobuf:"bytes,3,opt,name=default,proto3" json:"default,omitempty"` // Omit this field from graphql definition Omit bool `protobuf:"varint,4,opt,name=omit,proto3" json:"omit,omitempty"` // Resolve this field by nested query with additional RPC Resolver string `protobuf:"bytes,5,opt,name=resolver,proto3" json:"resolver,omitempty"` // contains filtered or unexported fields }
GraphqlField is FieldOptions in protobuf in order to define type field attribute. User can use this option as following:
message Member { string name = 1 [(graphql.field) = {required: true}]; // this field is required in GraphQL, it equivalent to String! on GraphQL }
message CreateMemberRequest { string name = 1; [(grahpql.field) = {default: "anonymous"}]; // use default value on input or query }
Note that in protobuf, all fields are dealt with optional so the same as it, all GraphQL fields are optional as default. If you need to be required, use 'required: true' option
func (*GraphqlField) Descriptor
deprecated
func (*GraphqlField) Descriptor() ([]byte, []int)
Deprecated: Use GraphqlField.ProtoReflect.Descriptor instead.
func (*GraphqlField) GetDefault ¶
func (x *GraphqlField) GetDefault() string
func (*GraphqlField) GetName ¶
func (x *GraphqlField) GetName() string
func (*GraphqlField) GetOmit ¶
func (x *GraphqlField) GetOmit() bool
func (*GraphqlField) GetRequired ¶
func (x *GraphqlField) GetRequired() bool
func (*GraphqlField) GetResolver ¶
func (x *GraphqlField) GetResolver() string
func (*GraphqlField) ProtoMessage ¶
func (*GraphqlField) ProtoMessage()
func (*GraphqlField) ProtoReflect ¶
func (x *GraphqlField) ProtoReflect() protoreflect.Message
func (*GraphqlField) Reset ¶
func (x *GraphqlField) Reset()
func (*GraphqlField) String ¶
func (x *GraphqlField) String() string
type GraphqlRequest ¶
type GraphqlRequest struct { // Define input name. // This field enables only for mutation and note that if this field is specified, // the gRPC request message will be dealt with an input. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Define pluck message fields Plucks []string `protobuf:"bytes,2,rep,name=plucks,proto3" json:"plucks,omitempty"` // contains filtered or unexported fields }
configuration option for request
func (*GraphqlRequest) Descriptor
deprecated
func (*GraphqlRequest) Descriptor() ([]byte, []int)
Deprecated: Use GraphqlRequest.ProtoReflect.Descriptor instead.
func (*GraphqlRequest) GetName ¶
func (x *GraphqlRequest) GetName() string
func (*GraphqlRequest) GetPlucks ¶
func (x *GraphqlRequest) GetPlucks() []string
func (*GraphqlRequest) ProtoMessage ¶
func (*GraphqlRequest) ProtoMessage()
func (*GraphqlRequest) ProtoReflect ¶
func (x *GraphqlRequest) ProtoReflect() protoreflect.Message
func (*GraphqlRequest) Reset ¶
func (x *GraphqlRequest) Reset()
func (*GraphqlRequest) String ¶
func (x *GraphqlRequest) String() string
type GraphqlResponse ¶
type GraphqlResponse struct { // If true, this response object is required // But when you declare "pluck", we respect expose field definition. Required bool `protobuf:"varint,1,opt,name=required,proto3" json:"required,omitempty"` // Define pluck message field. // Note that this field IS NOT repeated, just single string field. // It means the response could only be single. Pluck string `protobuf:"bytes,2,opt,name=pluck,proto3" json:"pluck,omitempty"` // contains filtered or unexported fields }
configuration option for response
func (*GraphqlResponse) Descriptor
deprecated
func (*GraphqlResponse) Descriptor() ([]byte, []int)
Deprecated: Use GraphqlResponse.ProtoReflect.Descriptor instead.
func (*GraphqlResponse) GetPluck ¶
func (x *GraphqlResponse) GetPluck() string
func (*GraphqlResponse) GetRequired ¶
func (x *GraphqlResponse) GetRequired() bool
func (*GraphqlResponse) ProtoMessage ¶
func (*GraphqlResponse) ProtoMessage()
func (*GraphqlResponse) ProtoReflect ¶
func (x *GraphqlResponse) ProtoReflect() protoreflect.Message
func (*GraphqlResponse) Reset ¶
func (x *GraphqlResponse) Reset()
func (*GraphqlResponse) String ¶
func (x *GraphqlResponse) String() string
type GraphqlSchema ¶
type GraphqlSchema struct { // graphql type. Enum of QUERY or MUTATION is valid value Type GraphqlType `protobuf:"varint,1,opt,name=type,proto3,enum=graphql.GraphqlType" json:"type,omitempty"` // query name. this field is required Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Query request object configuration Request *GraphqlRequest `protobuf:"bytes,3,opt,name=request,proto3" json:"request,omitempty"` // Query response object configuration Response *GraphqlResponse `protobuf:"bytes,4,opt,name=response,proto3" json:"response,omitempty"` // contains filtered or unexported fields }
Extend MethodOptions in order to define GraphQL Query or Mutation. User can use this option as following:
service Greeter { rpc SayHello(HelloRequest) returns (HelloReply) { option (graphql.schema) = { type: QUERY // declare as Query name: "hello" // query name } } }
Since gRPC reason, it has limitation that the response could not be repeated. it's dificcurl to respond array response, so that we accept "response.pluck" in order to expose repeated fields in response message.
For instance:
message Member { string name = 1; }
message ListMembersResponse { repeated Member members = 1; -- could be array response }
message ListMembersRequest { }
service MemberService { rpc ListMembers(ListMembersRequest) returns (ListMembersResponse) { option (graphql.schema) = { type: QUERY name: "members" response { repeated : true pluck: "members" // Query will respond [Member] instead of ListMembersResponse } } } }
In mutation declaration:
service MemberService { rpc CreateMember(CreateMemberRequest) returns (Member) { option (graphql.schema) = { type: MUTATION // declare as Mutation name: "cretemember" // mutation name } } }
The Mutation's input always becomes an input object, so you need to declare argument name.
message Member { string name = 1; }
message CreateMemberRequest { string name = 1; }
service MemberService { rpc CreateMember(CreateMemberRequest) returns (Member) { option (graphql.schema) = { type: MUTATION name: "createmember" request { name: "member" // this is equivalent to createbook(member: Member): Member in GraphQL } } } }
Finally, user can access this query via /graphql?query={members{name}}
func (*GraphqlSchema) Descriptor
deprecated
func (*GraphqlSchema) Descriptor() ([]byte, []int)
Deprecated: Use GraphqlSchema.ProtoReflect.Descriptor instead.
func (*GraphqlSchema) GetName ¶
func (x *GraphqlSchema) GetName() string
func (*GraphqlSchema) GetRequest ¶
func (x *GraphqlSchema) GetRequest() *GraphqlRequest
func (*GraphqlSchema) GetResponse ¶
func (x *GraphqlSchema) GetResponse() *GraphqlResponse
func (*GraphqlSchema) GetType ¶
func (x *GraphqlSchema) GetType() GraphqlType
func (*GraphqlSchema) ProtoMessage ¶
func (*GraphqlSchema) ProtoMessage()
func (*GraphqlSchema) ProtoReflect ¶
func (x *GraphqlSchema) ProtoReflect() protoreflect.Message
func (*GraphqlSchema) Reset ¶
func (x *GraphqlSchema) Reset()
func (*GraphqlSchema) String ¶
func (x *GraphqlSchema) String() string
type GraphqlService ¶
type GraphqlService struct { // gRPC default connection host. // This value should include host and port, say localhost:50051. Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` // If true, automatic connection with insecure option. Insecure bool `protobuf:"varint,2,opt,name=insecure,proto3" json:"insecure,omitempty"` // contains filtered or unexported fields }
Extend ServiceOptions in order to define grpc connection setting. User can use this option as following:
service Greeter { option (graphql.service) = { host: "localhost:50051" // define grpc connection host and port insecure: true // set true if connect to insecure grpc server }; ... some rpc definitions }
func (*GraphqlService) Descriptor
deprecated
func (*GraphqlService) Descriptor() ([]byte, []int)
Deprecated: Use GraphqlService.ProtoReflect.Descriptor instead.
func (*GraphqlService) GetHost ¶
func (x *GraphqlService) GetHost() string
func (*GraphqlService) GetInsecure ¶
func (x *GraphqlService) GetInsecure() bool
func (*GraphqlService) ProtoMessage ¶
func (*GraphqlService) ProtoMessage()
func (*GraphqlService) ProtoReflect ¶
func (x *GraphqlService) ProtoReflect() protoreflect.Message
func (*GraphqlService) Reset ¶
func (x *GraphqlService) Reset()
func (*GraphqlService) String ¶
func (x *GraphqlService) String() string
type GraphqlType ¶
type GraphqlType int32
explicit schema declaration enum
const ( // schema will generate as Query GraphqlType_QUERY GraphqlType = 0 // schema will generate as Mutation GraphqlType_MUTATION GraphqlType = 1 // schema will generate as Resolver. Resolver behaves not listed in query, but can resolve nested field. GraphqlType_RESOLVER GraphqlType = 2 )
func (GraphqlType) Descriptor ¶
func (GraphqlType) Descriptor() protoreflect.EnumDescriptor
func (GraphqlType) Enum ¶
func (x GraphqlType) Enum() *GraphqlType
func (GraphqlType) EnumDescriptor
deprecated
func (GraphqlType) EnumDescriptor() ([]byte, []int)
Deprecated: Use GraphqlType.Descriptor instead.
func (GraphqlType) Number ¶
func (x GraphqlType) Number() protoreflect.EnumNumber
func (GraphqlType) String ¶
func (x GraphqlType) String() string
func (GraphqlType) Type ¶
func (GraphqlType) Type() protoreflect.EnumType