mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
Update relay-runtime types
This commit is contained in:
Generated
+4
-4
@@ -1342,9 +1342,9 @@
|
||||
}
|
||||
},
|
||||
"@coralproject/rte": {
|
||||
"version": "0.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@coralproject/rte/-/rte-0.10.6.tgz",
|
||||
"integrity": "sha512-oUK/KSw28AkmpX5D8v1IkQT0iIxKxPmSG0euTFgqEthSgnAUQgoOmQengaR/nsS9zE31KPbbWMIAzH0aN/YwNA==",
|
||||
"version": "0.10.9",
|
||||
"resolved": "https://registry.npmjs.org/@coralproject/rte/-/rte-0.10.9.tgz",
|
||||
"integrity": "sha512-0K+bc3JaOhjgJJ91uupev4EmSoldd/IizfjRgAQ8LbZjRc3pWprzIBhoTMChApBzz7eI9DUfw2ULg5muziV8BA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bowser": "^1.0.0",
|
||||
@@ -2107,7 +2107,7 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/relay-runtime": {
|
||||
"version": "github:coralproject/patched#ba8d413696e97b4f67450de3525cc319b9980cba",
|
||||
"version": "github:coralproject/patched#c9a2387f6d32f092b9c75ddfca92d1856d2b41f6",
|
||||
"from": "github:coralproject/patched#types/relay-runtime",
|
||||
"dev": true
|
||||
},
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@
|
||||
"@babel/polyfill": "7.0.0-beta.49",
|
||||
"@babel/preset-env": "7.0.0-beta.49",
|
||||
"@babel/preset-react": "7.0.0-beta.49",
|
||||
"@coralproject/rte": "^0.10.6",
|
||||
"@coralproject/rte": "^0.10.9",
|
||||
"@types/bcryptjs": "^2.4.1",
|
||||
"@types/bunyan": "^1.8.4",
|
||||
"@types/case-sensitive-paths-webpack-plugin": "^2.1.2",
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
declare module "relay-runtime" {
|
||||
export const ROOT_ID: string;
|
||||
}
|
||||
|
||||
import { Environment, ROOT_ID } from "relay-runtime";
|
||||
|
||||
export default function getMe(environment: Environment) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { commitMutation } from "react-relay";
|
||||
import { Environment, MutationConfig } from "relay-runtime";
|
||||
import { Environment, MutationConfig, OperationBase } from "relay-runtime";
|
||||
|
||||
import { Omit } from "talk-framework/types";
|
||||
|
||||
@@ -7,8 +7,8 @@ import { Omit } from "talk-framework/types";
|
||||
* Like `MutationConfig` but omits `onCompleted` and `onError`
|
||||
* because we are going to use a Promise API.
|
||||
*/
|
||||
export type MutationPromiseConfig<T, U> = Omit<
|
||||
MutationConfig<T, U>,
|
||||
export type MutationPromiseConfig<T extends OperationBase> = Omit<
|
||||
MutationConfig<T>,
|
||||
"onCompleted" | "onError"
|
||||
>;
|
||||
|
||||
@@ -27,10 +27,10 @@ function getPayload(response: { [key: string]: any }): any {
|
||||
* and errors are wrapped inside of application specific
|
||||
* error instances.
|
||||
*/
|
||||
export async function commitMutationPromiseNormalized<R, V>(
|
||||
export async function commitMutationPromiseNormalized<T extends OperationBase>(
|
||||
environment: Environment,
|
||||
config: MutationPromiseConfig<R, V>
|
||||
): Promise<R> {
|
||||
config: MutationPromiseConfig<T>
|
||||
): Promise<T["response"][keyof T["response"]]> {
|
||||
try {
|
||||
const response = await commitMutationPromise(environment, config);
|
||||
return getPayload(response);
|
||||
@@ -42,10 +42,10 @@ export async function commitMutationPromiseNormalized<R, V>(
|
||||
/**
|
||||
* Like `commitMutation` of the Relay API but returns a Promise.
|
||||
*/
|
||||
export function commitMutationPromise<R, V>(
|
||||
export function commitMutationPromise<T extends OperationBase>(
|
||||
environment: Environment,
|
||||
config: MutationPromiseConfig<R, V>
|
||||
): Promise<R> {
|
||||
config: MutationPromiseConfig<T>
|
||||
): Promise<T["response"][keyof T["response"]]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
commitMutation(environment, {
|
||||
...config,
|
||||
|
||||
@@ -2,9 +2,9 @@ import * as React from "react";
|
||||
import { StatelessComponent } from "react";
|
||||
|
||||
import { Flex } from "talk-ui/components";
|
||||
|
||||
import PermalinkViewQuery from "../queries/PermalinkViewQuery";
|
||||
import StreamQuery from "../queries/StreamQuery";
|
||||
|
||||
import * as styles from "./App.css";
|
||||
|
||||
export interface AppProps {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Localized } from "fluent-react/compat";
|
||||
import React from "react";
|
||||
|
||||
import { oncePerFrame } from "talk-common/utils";
|
||||
import {
|
||||
Button,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { Component } from "react";
|
||||
import React, { Component, ReactNode } from "react";
|
||||
|
||||
import { BadUserInputError } from "talk-framework/lib/errors";
|
||||
import { PropTypesOf } from "talk-framework/types";
|
||||
@@ -11,6 +11,7 @@ import { CreateCommentMutation, withCreateCommentMutation } from "../mutations";
|
||||
interface InnerProps {
|
||||
createComment: CreateCommentMutation;
|
||||
assetID: string;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
class PostCommentFormContainer extends Component<InnerProps> {
|
||||
|
||||
@@ -23,7 +23,7 @@ export class ReplyListContainer extends React.Component<InnerProps> {
|
||||
|
||||
public render() {
|
||||
if (
|
||||
!this.props.comment.replies == null ||
|
||||
this.props.comment.replies == null ||
|
||||
this.props.comment.replies.edges.length === 0
|
||||
) {
|
||||
return null;
|
||||
|
||||
@@ -20,6 +20,7 @@ it("renders correctly", () => {
|
||||
edges: [{ node: { id: "comment-1" } }, { node: { id: "comment-2" } }],
|
||||
},
|
||||
},
|
||||
user: null,
|
||||
relay: {
|
||||
hasMore: noop,
|
||||
isLoading: noop,
|
||||
@@ -39,6 +40,7 @@ describe("when has more comments", () => {
|
||||
edges: [{ node: { id: "comment-1" } }, { node: { id: "comment-2" } }],
|
||||
},
|
||||
},
|
||||
user: null,
|
||||
relay: {
|
||||
hasMore: () => true,
|
||||
isLoading: () => false,
|
||||
|
||||
@@ -9,13 +9,10 @@ import {
|
||||
} from "talk-framework/lib/relay";
|
||||
import { Omit } from "talk-framework/types";
|
||||
|
||||
import {
|
||||
CreateCommentMutationResponse,
|
||||
CreateCommentMutationVariables,
|
||||
} from "talk-stream/__generated__/CreateCommentMutation.graphql";
|
||||
import { CreateCommentMutation } from "talk-stream/__generated__/CreateCommentMutation.graphql";
|
||||
|
||||
export type CreateCommentInput = Omit<
|
||||
CreateCommentMutationVariables["input"],
|
||||
CreateCommentMutation["variables"]["input"],
|
||||
"clientMutationId"
|
||||
>;
|
||||
|
||||
@@ -26,8 +23,12 @@ const mutation = graphql`
|
||||
cursor
|
||||
node {
|
||||
id
|
||||
...CommentContainer
|
||||
...ReplyListContainer_comment
|
||||
author {
|
||||
id
|
||||
username
|
||||
}
|
||||
body
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
clientMutationId
|
||||
@@ -40,10 +41,7 @@ let clientMutationId = 0;
|
||||
function commit(environment: Environment, input: CreateCommentInput) {
|
||||
const me = getMe(environment)!;
|
||||
const currentDate = new Date().toISOString();
|
||||
return commitMutationPromiseNormalized<
|
||||
CreateCommentMutationResponse["createComment"],
|
||||
CreateCommentMutationVariables
|
||||
>(environment, {
|
||||
return commitMutationPromiseNormalized<CreateCommentMutation>(environment, {
|
||||
mutation,
|
||||
variables: {
|
||||
input: {
|
||||
@@ -63,14 +61,6 @@ function commit(environment: Environment, input: CreateCommentInput) {
|
||||
username: me.username,
|
||||
},
|
||||
body: input.body,
|
||||
replies: {
|
||||
edges: [],
|
||||
pageInfo: {
|
||||
endCursor: null,
|
||||
hasNextPage: false,
|
||||
},
|
||||
},
|
||||
__typename: "Comment",
|
||||
},
|
||||
},
|
||||
clientMutationId: (clientMutationId++).toString(),
|
||||
@@ -100,4 +90,4 @@ export const withCreateCommentMutation = createMutationContainer(
|
||||
|
||||
export type CreateCommentMutation = (
|
||||
input: CreateCommentInput
|
||||
) => Promise<CreateCommentMutationResponse["createComment"]>;
|
||||
) => Promise<CreateCommentMutation["response"]["createComment"]>;
|
||||
|
||||
@@ -577,7 +577,7 @@ type Comment {
|
||||
"""
|
||||
createdAt is the date in which the comment was created.
|
||||
"""
|
||||
createdAt: Time
|
||||
createdAt: Time!
|
||||
|
||||
"""
|
||||
author is the User that authored the Comment.
|
||||
|
||||
Reference in New Issue
Block a user