mirror of
https://github.com/wassname/talk.git
synced 2026-07-01 20:07:49 +08:00
Upgrade react-relay types
This commit is contained in:
Generated
+2
-2
@@ -2069,7 +2069,7 @@
|
||||
}
|
||||
},
|
||||
"@types/react-relay": {
|
||||
"version": "github:coralproject/patched#ba4c8d01bb737e5f073534b32d870294e39cc5a8",
|
||||
"version": "github:coralproject/patched#c8e07adee83418ca04acfc99a3c542e082d70116",
|
||||
"from": "github:coralproject/patched#types/react-relay",
|
||||
"dev": true
|
||||
},
|
||||
@@ -8617,7 +8617,7 @@
|
||||
"dependencies": {
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"lint:scripts": "tslint --project ./tsconfig.json",
|
||||
"lint-fix": "npm run lint:server -- --fix && npm run lint:client -- --fix && npm run lint:client-embed -- --fix && npm run lint:scripts -- --fix",
|
||||
"test": "node scripts/test.js --env=jsdom",
|
||||
"tscheck": "npm-run-all --parallel tscheck:*",
|
||||
"tscheck:server": "tsc --project ./src/tsconfig.json --noEmit",
|
||||
"tscheck:client": "tsc --project ./src/core/client/tsconfig.json --noEmit",
|
||||
"tscheck:client-embed": "tsc --project ./src/core/client/embed/tsconfig.json --noEmit",
|
||||
|
||||
@@ -3,23 +3,25 @@ import {
|
||||
QueryRenderer,
|
||||
QueryRendererProps as QueryRendererPropsOrig,
|
||||
} from "react-relay";
|
||||
import { OperationBase, OperationDefaults } from "relay-runtime";
|
||||
|
||||
import { Omit } from "talk-framework/types";
|
||||
|
||||
import { TalkContextConsumer } from "../bootstrap/TalkContext";
|
||||
|
||||
// Omit environment as we are passing this from the context.
|
||||
export type QueryRendererProps<V, R> = Omit<
|
||||
QueryRendererPropsOrig<V, R>,
|
||||
"environment"
|
||||
>;
|
||||
export type QueryRendererProps<
|
||||
T extends OperationBase = OperationDefaults
|
||||
> = Omit<QueryRendererPropsOrig<T>, "environment">;
|
||||
|
||||
/**
|
||||
* TalkQueryRenderer is a wrappper around Relay's `QueryRenderer`.
|
||||
* It supplies the `environment` from the context and has better
|
||||
* generics type support.
|
||||
*/
|
||||
class TalkQueryRenderer<V, R> extends Component<QueryRendererProps<V, R>> {
|
||||
class TalkQueryRenderer<
|
||||
T extends OperationBase = OperationDefaults
|
||||
> extends Component<QueryRendererProps<T>> {
|
||||
public render() {
|
||||
return (
|
||||
<TalkContextConsumer>
|
||||
|
||||
@@ -9,10 +9,10 @@ import {
|
||||
} from "talk-framework/lib/relay";
|
||||
import { Omit } from "talk-framework/types";
|
||||
|
||||
import { CreateCommentMutation as CreateCommentType } from "talk-stream/__generated__/CreateCommentMutation.graphql";
|
||||
import { CreateCommentMutation as MutationTypes } from "talk-stream/__generated__/CreateCommentMutation.graphql";
|
||||
|
||||
export type CreateCommentInput = Omit<
|
||||
CreateCommentType["variables"]["input"],
|
||||
MutationTypes["variables"]["input"],
|
||||
"clientMutationId"
|
||||
>;
|
||||
|
||||
@@ -41,7 +41,7 @@ let clientMutationId = 0;
|
||||
function commit(environment: Environment, input: CreateCommentInput) {
|
||||
const me = getMe(environment)!;
|
||||
const currentDate = new Date().toISOString();
|
||||
return commitMutationPromiseNormalized<CreateCommentType>(environment, {
|
||||
return commitMutationPromiseNormalized<MutationTypes>(environment, {
|
||||
mutation,
|
||||
variables: {
|
||||
input: {
|
||||
@@ -90,4 +90,4 @@ export const withCreateCommentMutation = createMutationContainer(
|
||||
|
||||
export type CreateCommentMutation = (
|
||||
input: CreateCommentInput
|
||||
) => Promise<CreateCommentType["response"]["createComment"]>;
|
||||
) => Promise<MutationTypes["response"]["createComment"]>;
|
||||
|
||||
@@ -7,10 +7,7 @@ import {
|
||||
QueryRenderer,
|
||||
withLocalStateContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import {
|
||||
PermalinkViewQueryResponse,
|
||||
PermalinkViewQueryVariables,
|
||||
} from "talk-stream/__generated__/PermalinkViewQuery.graphql";
|
||||
import { PermalinkViewQuery as QueryTypes } from "talk-stream/__generated__/PermalinkViewQuery.graphql";
|
||||
import { PermalinkViewQueryLocal as Local } from "talk-stream/__generated__/PermalinkViewQueryLocal.graphql";
|
||||
|
||||
import { Spinner } from "talk-ui/components";
|
||||
@@ -23,7 +20,7 @@ interface InnerProps {
|
||||
export const render = ({
|
||||
error,
|
||||
props,
|
||||
}: ReadyState<PermalinkViewQueryResponse>) => {
|
||||
}: ReadyState<QueryTypes["response"]>) => {
|
||||
if (error) {
|
||||
return <div>{error.message}</div>;
|
||||
}
|
||||
@@ -36,7 +33,7 @@ export const render = ({
|
||||
const PermalinkViewQuery: StatelessComponent<InnerProps> = ({
|
||||
local: { commentID },
|
||||
}) => (
|
||||
<QueryRenderer<PermalinkViewQueryVariables, PermalinkViewQueryResponse>
|
||||
<QueryRenderer<QueryTypes>
|
||||
query={graphql`
|
||||
query PermalinkViewQuery($commentID: ID!) {
|
||||
comment(id: $commentID) {
|
||||
@@ -45,7 +42,7 @@ const PermalinkViewQuery: StatelessComponent<InnerProps> = ({
|
||||
}
|
||||
`}
|
||||
variables={{
|
||||
commentID,
|
||||
commentID: commentID!,
|
||||
}}
|
||||
render={render}
|
||||
/>
|
||||
|
||||
@@ -5,10 +5,7 @@ import {
|
||||
QueryRenderer,
|
||||
withLocalStateContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import {
|
||||
StreamQueryResponse,
|
||||
StreamQueryVariables,
|
||||
} from "talk-stream/__generated__/StreamQuery.graphql";
|
||||
import { StreamQuery as QueryTypes } from "talk-stream/__generated__/StreamQuery.graphql";
|
||||
import { StreamQueryLocal as Local } from "talk-stream/__generated__/StreamQueryLocal.graphql";
|
||||
import { Spinner } from "talk-ui/components";
|
||||
import StreamContainer from "../containers/StreamContainer";
|
||||
@@ -17,7 +14,10 @@ interface InnerProps {
|
||||
local: Local;
|
||||
}
|
||||
|
||||
export const render = ({ error, props }: ReadyState<StreamQueryResponse>) => {
|
||||
export const render = ({
|
||||
error,
|
||||
props,
|
||||
}: ReadyState<QueryTypes["response"]>) => {
|
||||
if (error) {
|
||||
return <div>{error.message}</div>;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export const render = ({ error, props }: ReadyState<StreamQueryResponse>) => {
|
||||
const StreamQuery: StatelessComponent<InnerProps> = ({
|
||||
local: { assetID, authRevision },
|
||||
}) => (
|
||||
<QueryRenderer<StreamQueryVariables, StreamQueryResponse>
|
||||
<QueryRenderer<QueryTypes>
|
||||
query={graphql`
|
||||
query StreamQuery($assetID: ID!, $authRevision: Int!) {
|
||||
asset(id: $assetID) {
|
||||
@@ -47,7 +47,7 @@ const StreamQuery: StatelessComponent<InnerProps> = ({
|
||||
}
|
||||
`}
|
||||
variables={{
|
||||
assetID,
|
||||
assetID: assetID!,
|
||||
authRevision,
|
||||
}}
|
||||
render={render}
|
||||
|
||||
Reference in New Issue
Block a user