Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ plugin-generate:
$(wgc_router) plugin build ./pkg/subgraphs/courses --generate-only

plugin-build-bun-binary:
cd pkg/subgraphs/courses/ && \
bun install && bun build src/plugin.ts --compile --outfile bin/$(shell go env GOOS)_$(shell go env GOARCH) && \
mkdir -p bin/grpc-health-check && \
cp -r node_modules/grpc-health-check/proto bin/grpc-health-check
$(wgc_router) plugin build ./pkg/subgraphs/courses

plugin-build-go-binary:
cd pkg/subgraphs/projects/ && go build -o ./bin/$(shell go env GOOS)_$(shell go env GOARCH) ./src
Expand Down
16 changes: 0 additions & 16 deletions demo/pkg/subgraphs/courses/generated/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,6 @@
}
],
"entityMappings": [
{
"typeName": "Course",
"kind": "entity",
"key": "id",
"rpc": "LookupCourseById",
"request": "LookupCourseByIdRequest",
"response": "LookupCourseByIdResponse"
},
{
"typeName": "Lesson",
"kind": "entity",
"key": "id",
"rpc": "LookupLessonById",
"request": "LookupLessonByIdRequest",
"response": "LookupLessonByIdResponse"
},
{
"typeName": "Employee",
"kind": "entity",
Expand Down
82 changes: 5 additions & 77 deletions demo/pkg/subgraphs/courses/generated/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import "google/protobuf/wrappers.proto";

// Service definition for CoursesService
service CoursesService {
// Lookup Course entity by id
rpc LookupCourseById(LookupCourseByIdRequest) returns (LookupCourseByIdResponse) {}
// Lookup Employee entity by id
rpc LookupEmployeeById(LookupEmployeeByIdRequest) returns (LookupEmployeeByIdResponse) {}
// Lookup Lesson entity by id
rpc LookupLessonById(LookupLessonByIdRequest) returns (LookupLessonByIdResponse) {}
rpc MutationAddCourse(MutationAddCourseRequest) returns (MutationAddCourseResponse) {}
rpc MutationAddLesson(MutationAddLessonRequest) returns (MutationAddLessonResponse) {}
rpc QueryCourse(QueryCourseRequest) returns (QueryCourseResponse) {}
Expand All @@ -20,74 +16,6 @@ service CoursesService {
rpc QueryThrowErrorCourses(QueryThrowErrorCoursesRequest) returns (QueryThrowErrorCoursesResponse) {}
}

// Key message for Course entity lookup
message LookupCourseByIdRequestKey {
// Key field for Course entity lookup.
string id = 1;
}

// Request message for Course entity lookup.
message LookupCourseByIdRequest {
/*
* List of keys to look up Course entities.
* Order matters - each key maps to one entity in LookupCourseByIdResponse.
*/
repeated LookupCourseByIdRequestKey keys = 1;
}

// Response message for Course entity lookup.
message LookupCourseByIdResponse {
/*
* List of Course entities in the same order as the keys in LookupCourseByIdRequest.
* Always return the same number of entities as keys. Use null for entities that cannot be found.
*
* Example:
* LookupUserByIdRequest:
* keys:
* - id: 1
* - id: 2
* LookupUserByIdResponse:
* result:
* - id: 1 # User with id 1 found
* - null # User with id 2 not found
*/
repeated Course result = 1;
}

// Key message for Lesson entity lookup
message LookupLessonByIdRequestKey {
// Key field for Lesson entity lookup.
string id = 1;
}

// Request message for Lesson entity lookup.
message LookupLessonByIdRequest {
/*
* List of keys to look up Lesson entities.
* Order matters - each key maps to one entity in LookupLessonByIdResponse.
*/
repeated LookupLessonByIdRequestKey keys = 1;
}

// Response message for Lesson entity lookup.
message LookupLessonByIdResponse {
/*
* List of Lesson entities in the same order as the keys in LookupLessonByIdRequest.
* Always return the same number of entities as keys. Use null for entities that cannot be found.
*
* Example:
* LookupUserByIdRequest:
* keys:
* - id: 1
* - id: 2
* LookupUserByIdResponse:
* result:
* - id: 1 # User with id 1 found
* - null # User with id 2 not found
*/
repeated Lesson result = 1;
}

// Key message for Employee entity lookup
message LookupEmployeeByIdRequestKey {
// Key field for Employee entity lookup.
Expand Down Expand Up @@ -179,6 +107,11 @@ message MutationAddLessonResponse {
Lesson add_lesson = 1;
}

message Employee {
int32 id = 1;
repeated Course taught_courses = 2;
}

message Course {
string id = 1;
string title = 2;
Expand All @@ -194,9 +127,4 @@ message Lesson {
google.protobuf.StringValue description = 4;
int32 order = 5;
Course course = 6;
}

message Employee {
int32 id = 1;
repeated Course taught_courses = 2;
}
34 changes: 0 additions & 34 deletions demo/pkg/subgraphs/courses/generated/service_grpc_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import * as service_pb from "./service_pb";
import * as google_protobuf_wrappers_pb from "google-protobuf/google/protobuf/wrappers_pb";

interface ICoursesServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
lookupCourseById: ICoursesServiceService_ILookupCourseById;
lookupEmployeeById: ICoursesServiceService_ILookupEmployeeById;
lookupLessonById: ICoursesServiceService_ILookupLessonById;
mutationAddCourse: ICoursesServiceService_IMutationAddCourse;
mutationAddLesson: ICoursesServiceService_IMutationAddLesson;
queryCourse: ICoursesServiceService_IQueryCourse;
Expand All @@ -21,15 +19,6 @@ interface ICoursesServiceService extends grpc.ServiceDefinition<grpc.UntypedServ
queryThrowErrorCourses: ICoursesServiceService_IQueryThrowErrorCourses;
}

interface ICoursesServiceService_ILookupCourseById extends grpc.MethodDefinition<service_pb.LookupCourseByIdRequest, service_pb.LookupCourseByIdResponse> {
path: "/service.CoursesService/LookupCourseById";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<service_pb.LookupCourseByIdRequest>;
requestDeserialize: grpc.deserialize<service_pb.LookupCourseByIdRequest>;
responseSerialize: grpc.serialize<service_pb.LookupCourseByIdResponse>;
responseDeserialize: grpc.deserialize<service_pb.LookupCourseByIdResponse>;
}
interface ICoursesServiceService_ILookupEmployeeById extends grpc.MethodDefinition<service_pb.LookupEmployeeByIdRequest, service_pb.LookupEmployeeByIdResponse> {
path: "/service.CoursesService/LookupEmployeeById";
requestStream: false;
Expand All @@ -39,15 +28,6 @@ interface ICoursesServiceService_ILookupEmployeeById extends grpc.MethodDefiniti
responseSerialize: grpc.serialize<service_pb.LookupEmployeeByIdResponse>;
responseDeserialize: grpc.deserialize<service_pb.LookupEmployeeByIdResponse>;
}
interface ICoursesServiceService_ILookupLessonById extends grpc.MethodDefinition<service_pb.LookupLessonByIdRequest, service_pb.LookupLessonByIdResponse> {
path: "/service.CoursesService/LookupLessonById";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<service_pb.LookupLessonByIdRequest>;
requestDeserialize: grpc.deserialize<service_pb.LookupLessonByIdRequest>;
responseSerialize: grpc.serialize<service_pb.LookupLessonByIdResponse>;
responseDeserialize: grpc.deserialize<service_pb.LookupLessonByIdResponse>;
}
interface ICoursesServiceService_IMutationAddCourse extends grpc.MethodDefinition<service_pb.MutationAddCourseRequest, service_pb.MutationAddCourseResponse> {
path: "/service.CoursesService/MutationAddCourse";
requestStream: false;
Expand Down Expand Up @@ -115,9 +95,7 @@ interface ICoursesServiceService_IQueryThrowErrorCourses extends grpc.MethodDefi
export const CoursesServiceService: ICoursesServiceService;

export interface ICoursesServiceServer extends grpc.UntypedServiceImplementation {
lookupCourseById: grpc.handleUnaryCall<service_pb.LookupCourseByIdRequest, service_pb.LookupCourseByIdResponse>;
lookupEmployeeById: grpc.handleUnaryCall<service_pb.LookupEmployeeByIdRequest, service_pb.LookupEmployeeByIdResponse>;
lookupLessonById: grpc.handleUnaryCall<service_pb.LookupLessonByIdRequest, service_pb.LookupLessonByIdResponse>;
mutationAddCourse: grpc.handleUnaryCall<service_pb.MutationAddCourseRequest, service_pb.MutationAddCourseResponse>;
mutationAddLesson: grpc.handleUnaryCall<service_pb.MutationAddLessonRequest, service_pb.MutationAddLessonResponse>;
queryCourse: grpc.handleUnaryCall<service_pb.QueryCourseRequest, service_pb.QueryCourseResponse>;
Expand All @@ -128,15 +106,9 @@ export interface ICoursesServiceServer extends grpc.UntypedServiceImplementation
}

export interface ICoursesServiceClient {
lookupCourseById(request: service_pb.LookupCourseByIdRequest, callback: (error: grpc.ServiceError | null, response: service_pb.LookupCourseByIdResponse) => void): grpc.ClientUnaryCall;
lookupCourseById(request: service_pb.LookupCourseByIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.LookupCourseByIdResponse) => void): grpc.ClientUnaryCall;
lookupCourseById(request: service_pb.LookupCourseByIdRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.LookupCourseByIdResponse) => void): grpc.ClientUnaryCall;
lookupEmployeeById(request: service_pb.LookupEmployeeByIdRequest, callback: (error: grpc.ServiceError | null, response: service_pb.LookupEmployeeByIdResponse) => void): grpc.ClientUnaryCall;
lookupEmployeeById(request: service_pb.LookupEmployeeByIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.LookupEmployeeByIdResponse) => void): grpc.ClientUnaryCall;
lookupEmployeeById(request: service_pb.LookupEmployeeByIdRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.LookupEmployeeByIdResponse) => void): grpc.ClientUnaryCall;
lookupLessonById(request: service_pb.LookupLessonByIdRequest, callback: (error: grpc.ServiceError | null, response: service_pb.LookupLessonByIdResponse) => void): grpc.ClientUnaryCall;
lookupLessonById(request: service_pb.LookupLessonByIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.LookupLessonByIdResponse) => void): grpc.ClientUnaryCall;
lookupLessonById(request: service_pb.LookupLessonByIdRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.LookupLessonByIdResponse) => void): grpc.ClientUnaryCall;
mutationAddCourse(request: service_pb.MutationAddCourseRequest, callback: (error: grpc.ServiceError | null, response: service_pb.MutationAddCourseResponse) => void): grpc.ClientUnaryCall;
mutationAddCourse(request: service_pb.MutationAddCourseRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.MutationAddCourseResponse) => void): grpc.ClientUnaryCall;
mutationAddCourse(request: service_pb.MutationAddCourseRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.MutationAddCourseResponse) => void): grpc.ClientUnaryCall;
Expand All @@ -162,15 +134,9 @@ export interface ICoursesServiceClient {

export class CoursesServiceClient extends grpc.Client implements ICoursesServiceClient {
constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial<grpc.ClientOptions>);
public lookupCourseById(request: service_pb.LookupCourseByIdRequest, callback: (error: grpc.ServiceError | null, response: service_pb.LookupCourseByIdResponse) => void): grpc.ClientUnaryCall;
public lookupCourseById(request: service_pb.LookupCourseByIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.LookupCourseByIdResponse) => void): grpc.ClientUnaryCall;
public lookupCourseById(request: service_pb.LookupCourseByIdRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.LookupCourseByIdResponse) => void): grpc.ClientUnaryCall;
public lookupEmployeeById(request: service_pb.LookupEmployeeByIdRequest, callback: (error: grpc.ServiceError | null, response: service_pb.LookupEmployeeByIdResponse) => void): grpc.ClientUnaryCall;
public lookupEmployeeById(request: service_pb.LookupEmployeeByIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.LookupEmployeeByIdResponse) => void): grpc.ClientUnaryCall;
public lookupEmployeeById(request: service_pb.LookupEmployeeByIdRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.LookupEmployeeByIdResponse) => void): grpc.ClientUnaryCall;
public lookupLessonById(request: service_pb.LookupLessonByIdRequest, callback: (error: grpc.ServiceError | null, response: service_pb.LookupLessonByIdResponse) => void): grpc.ClientUnaryCall;
public lookupLessonById(request: service_pb.LookupLessonByIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.LookupLessonByIdResponse) => void): grpc.ClientUnaryCall;
public lookupLessonById(request: service_pb.LookupLessonByIdRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.LookupLessonByIdResponse) => void): grpc.ClientUnaryCall;
public mutationAddCourse(request: service_pb.MutationAddCourseRequest, callback: (error: grpc.ServiceError | null, response: service_pb.MutationAddCourseResponse) => void): grpc.ClientUnaryCall;
public mutationAddCourse(request: service_pb.MutationAddCourseRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: service_pb.MutationAddCourseResponse) => void): grpc.ClientUnaryCall;
public mutationAddCourse(request: service_pb.MutationAddCourseRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: service_pb.MutationAddCourseResponse) => void): grpc.ClientUnaryCall;
Expand Down
68 changes: 0 additions & 68 deletions demo/pkg/subgraphs/courses/generated/service_grpc_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,6 @@ var grpc = require('@grpc/grpc-js');
var service_pb = require('./service_pb.js');
var google_protobuf_wrappers_pb = require('google-protobuf/google/protobuf/wrappers_pb.js');

function serialize_service_LookupCourseByIdRequest(arg) {
if (!(arg instanceof service_pb.LookupCourseByIdRequest)) {
throw new Error('Expected argument of type service.LookupCourseByIdRequest');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_service_LookupCourseByIdRequest(buffer_arg) {
return service_pb.LookupCourseByIdRequest.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_service_LookupCourseByIdResponse(arg) {
if (!(arg instanceof service_pb.LookupCourseByIdResponse)) {
throw new Error('Expected argument of type service.LookupCourseByIdResponse');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_service_LookupCourseByIdResponse(buffer_arg) {
return service_pb.LookupCourseByIdResponse.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_service_LookupEmployeeByIdRequest(arg) {
if (!(arg instanceof service_pb.LookupEmployeeByIdRequest)) {
throw new Error('Expected argument of type service.LookupEmployeeByIdRequest');
Expand All @@ -49,28 +27,6 @@ function deserialize_service_LookupEmployeeByIdResponse(buffer_arg) {
return service_pb.LookupEmployeeByIdResponse.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_service_LookupLessonByIdRequest(arg) {
if (!(arg instanceof service_pb.LookupLessonByIdRequest)) {
throw new Error('Expected argument of type service.LookupLessonByIdRequest');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_service_LookupLessonByIdRequest(buffer_arg) {
return service_pb.LookupLessonByIdRequest.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_service_LookupLessonByIdResponse(arg) {
if (!(arg instanceof service_pb.LookupLessonByIdResponse)) {
throw new Error('Expected argument of type service.LookupLessonByIdResponse');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_service_LookupLessonByIdResponse(buffer_arg) {
return service_pb.LookupLessonByIdResponse.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_service_MutationAddCourseRequest(arg) {
if (!(arg instanceof service_pb.MutationAddCourseRequest)) {
throw new Error('Expected argument of type service.MutationAddCourseRequest');
Expand Down Expand Up @@ -228,18 +184,6 @@ function deserialize_service_QueryThrowErrorCoursesResponse(buffer_arg) {

// Service definition for CoursesService
var CoursesServiceService = exports.CoursesServiceService = {
// Lookup Course entity by id
lookupCourseById: {
path: '/service.CoursesService/LookupCourseById',
requestStream: false,
responseStream: false,
requestType: service_pb.LookupCourseByIdRequest,
responseType: service_pb.LookupCourseByIdResponse,
requestSerialize: serialize_service_LookupCourseByIdRequest,
requestDeserialize: deserialize_service_LookupCourseByIdRequest,
responseSerialize: serialize_service_LookupCourseByIdResponse,
responseDeserialize: deserialize_service_LookupCourseByIdResponse,
},
// Lookup Employee entity by id
lookupEmployeeById: {
path: '/service.CoursesService/LookupEmployeeById',
Expand All @@ -252,18 +196,6 @@ lookupEmployeeById: {
responseSerialize: serialize_service_LookupEmployeeByIdResponse,
responseDeserialize: deserialize_service_LookupEmployeeByIdResponse,
},
// Lookup Lesson entity by id
lookupLessonById: {
path: '/service.CoursesService/LookupLessonById',
requestStream: false,
responseStream: false,
requestType: service_pb.LookupLessonByIdRequest,
responseType: service_pb.LookupLessonByIdResponse,
requestSerialize: serialize_service_LookupLessonByIdRequest,
requestDeserialize: deserialize_service_LookupLessonByIdRequest,
responseSerialize: serialize_service_LookupLessonByIdResponse,
responseDeserialize: deserialize_service_LookupLessonByIdResponse,
},
mutationAddCourse: {
path: '/service.CoursesService/MutationAddCourse',
requestStream: false,
Expand Down
Loading
Loading