Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promiseclient missing from Typescript #580

Closed
Globegitter opened this issue Jun 28, 2019 · 5 comments · Fixed by #746
Closed

promiseclient missing from Typescript #580

Globegitter opened this issue Jun 28, 2019 · 5 comments · Fixed by #746

Comments

@Globegitter
Copy link
Contributor

Just trying out the typescript generation and it seems like the promiseclient is missing there. Would be great to have for parity.

@yoitsro
Copy link

yoitsro commented Jul 9, 2019

@Globegitter I have the promise client defined when I generate my typescript definitions. The server definitions get put in a file named with the following format myservice_grpc_web_pb.d.ts.

It contains the traditional callback interface and the promise based interface. What gets produced when you generate your typescript definitions?

@Globegitter
Copy link
Contributor Author

Globegitter commented Jul 12, 2019

@yoitsro I am testing with the code at this repository: https://github.com/Globegitter/kotlin-react-grpc-example and getting a file HelloworldServiceClientPb.ts with following content:

/**
 * @fileoverview gRPC-Web generated client stub for helloworld
 * @enhanceable
 * @public
 */

// GENERATED CODE -- DO NOT EDIT!


import * as grpcWeb from 'grpc-web';

import {
  HelloReply,
  HelloRequest} from './helloworld_pb';

export class GreeterClient {
  client_: grpcWeb.AbstractClientBase;
  hostname_: string;
  credentials_: null | { [index: string]: string; };
  options_: null | { [index: string]: string; };

  constructor (hostname: string,
               credentials?: null | { [index: string]: string; },
               options?: null | { [index: string]: string; }) {
    if (!options) options = {};
    if (!credentials) credentials = {};
    options['format'] = 'text';

    this.client_ = new grpcWeb.GrpcWebClientBase(options);
    this.hostname_ = hostname;
    this.credentials_ = credentials;
    this.options_ = options;
  }

  methodInfoSayHello = new grpcWeb.AbstractClientBase.MethodInfo(
    HelloReply,
    (request: HelloRequest) => {
      return request.serializeBinary();
    },
    HelloReply.deserializeBinary
  );

  sayHello(
    request: HelloRequest,
    metadata: grpcWeb.Metadata | null,
    callback: (err: grpcWeb.Error,
               response: HelloReply) => void) {
    return this.client_.rpcCall(
      this.hostname_ +
        '/helloworld.Greeter/SayHello',
      request,
      metadata || {},
      this.methodInfoSayHello,
      callback);
  }

  methodInfoSayHelloServerStreaming = new grpcWeb.AbstractClientBase.MethodInfo(
    HelloReply,
    (request: HelloRequest) => {
      return request.serializeBinary();
    },
    HelloReply.deserializeBinary
  );

  sayHelloServerStreaming(
    request: HelloRequest,
    metadata?: grpcWeb.Metadata) {
    return this.client_.serverStreaming(
      this.hostname_ +
        '/helloworld.Greeter/SayHelloServerStreaming',
      request,
      metadata || {},
      this.methodInfoSayHelloServerStreaming);
  }

}

@yoitsro
Copy link

yoitsro commented Jul 12, 2019

What command are you running to generate this?

@Globegitter
Copy link
Contributor Author

Globegitter commented Jul 15, 2019

@yoitsro You can see it in the repository, it is auto-generated by gradle via: https://github.com/google/protobuf-gradle-plugin - here are the options specified: https://github.com/Globegitter/kotlin-react-grpc-example/blob/master/customer-service/app/build.gradle.kts#L98

What command are you running? Maybe I can then also give it a try manually and compare the outputs.

@yoitsro
Copy link

yoitsro commented Jul 15, 2019

Ah, hold on. I'm so sorry! I've been using the commonjs+dts output options. Using this option outputs the promise client with TypeScript bindings.

I just tried outputting TypeScript directly and you're right, there is no promise client yet. Again, I'm so sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants