Skip to content

Can I use this library to generate a graphql response payload? #252

@zhaoyi0113

Description

@zhaoyi0113

Thanks for releasing this awesome library. I am looking for a way to generate graphql response payload from raw data.
What am doing is to take raw data from database and publish this data to subscribers via graphql subscription websocket. I have a schema like:

type Message {
  msg: String!
  id: ID!
  topic: String!
}

type Mutation {
  sendChat(topic: String!, message: String!): ID!
}

type Query {
  getChat(id: ID!): String!
}

type Subscription {
  # Subscribe to events on the given topic.
  event(
    # Name of the topic to subscribe to.
    on: String!
  ): Message!
}

when there is a need to publish Message data to subscribers, I will need to convert the raw data: { event: { msg: 'hello', topic: 'xxxx' } } to a payload the Apollo client expects.

Is there a way I can do that by using this library? The payload needs to include the __typename as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions