問題タブ [apollostack]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
2 に答える
826 参照

graphql - GraphQL をカスケードするには?

現在、RESTful エンドポイントを GraphQL エンドポイントにラップするために「クライアント側 GraphQL サーバー」を使用しています。

しかし、サーバー側も GraphQL エンドポイントである場合はどうなるでしょうか? 軽量な方法で GraphQL サーバー内の別の GraphQL サーバーをキューに入れるにはどうすればよいですか?

または、より一般的には、マイクロサービスを提供する GraphQL サーバー "A" と "B" がある場合、GraphQL サーバー "C" を使用して "A" と "B" を統合します。「C」で「A」と「B」をキューに入れるには、apollo-client などを使用してある種の「サーバー側クライアント」を使用する必要がありますか?

0 投票する
1 に答える
898 参照

graphql - Apollo Query は GraphIQL で機能しますが、graphql() の呼び出しでは機能しませんか?

localhost:3010/graphiql で正しく動作する Apollo クエリがあります。

クエリ

クエリ変数

graphql() への呼び出しを介してクエリを実行するコードは次のとおりです。

Chrome Network タブには、予想されるリクエスト ペイロードが表示されます。

operationName:"getIMs" query: "query getIMs($fromID: String!, $toID: String!) {↵ instant_message(fromID: $fromID, toID: $toID) {↵<br> fromID↵ toID↵ msgText↵ __typename↵ }↵}↵" 変数:{fromID: "DsmkoaYPeAumREsqC", toID: "572bddac4ecbbac0ffe37fdd"} fromID:"DsmkoaYPeAumREsqC" toID:"572bddac4ecbbac0ffe37fdd"

しかし、dataオブジェクトは ApolloError で戻ってきます:

「ネットワーク エラー: 予期しないトークン < 位置 0 の JSON 内」

どうすればこれを修正できますか?

アップデート

[ネットワーク] タブのスクリーン ショットを次に示します。

ここに画像の説明を入力

0 投票する
1 に答える
42 参照

javascript - 同じ redux 状態をリッスンするコンポーネントのレベル

私の状況は次のとおりです。

次のタイプのオブジェクトにすぎない、還元状態に 1 つのフィールドがあります{String, [{String, Float}]}。私の状態のこのフィールドは、2 つのコンポーネント (を変数として使用して GraphQL をクエリする) によって使用されますString

両方のコンポーネントは、connect(デコレータ構文を使用して) メソッドを介して接続されます。

これは他のすべてで機能するため、特別なことは何もありませんComponent。それでも、renderメソッドで状態をログに記録しながら、同じレベルでこれらのコンポーネントを呼び出すと、次のようになります。

Component1状態をそのままログにComponent2記録し、初期状態をログに記録します。コンポーネントを所定の位置に切り替えると、次のようになります。

逆のことが起こります:Component2正しい状態を記録しますが、記録Component1しません。

コンポーネントのいずれかを相互にComponent1呼び出すと (Component2レンダリングの一部として呼び出す場合)、すべて問題ありません。

ここで何が起こっているのかわかりません。また、同じ場所で同じ状態をリッスンしている 2 つのコンポーネントを呼び出すべきではないというドキュメントも見つかりません。

誰かが何が起こっているのかを理解するのを手伝ってくれることを願っています

0 投票する
2 に答える
3218 参照

graphql - After a mutation, how do I update the affected data across views?

enter image description here

I have both the getMovies query and addMovie mutation working. When addMovie happens though, I'm wondering how to best update the list of movies in "Edit Movies" and "My Profile" to reflect the changes. I just need a general/high-level overview, or even just the name of a concept if it's simple, on how to make this happen.

My initial thought was just to hold all of the movies in my Redux store. When the mutation finishes, it should return the newly added movie, which I can concatenate to the movies of my store.

After "Add Movie", it would pop back to the "Edit Movies" screen where you should be able to see the newly added movie, then if you go back to "My Profile", it'd be there too.

Is there a better way to do this than holding it all in my own Redux store? Is there any Apollo magic I don't know about that could possibly handle this update for me?


EDIT: I discovered the idea of updateQueries: http://dev.apollodata.com/react/cache-updates.html#updateQueries I think this is what I want (please let me know if this is not the right approach). This seems better than the traditional way of using my own Redux store.

#xA;

After addMovie mutation, this properly updates the view in "My Profile" because it uses the getMovies query (woah)! I'm then passing these movies as props into "Edit Movies", so how do I update it there as well? Should I just have them both use the getMovies query? Is there a way to pull the new result of getMovies out of the store, so I can reuse it on "Edit Movies" without doing the query again?


EDIT2: Wrapping MyProfile and EditMovies both with getMovies query container seems to work fine. After addMovie, it's updated in both places due to updateQueries on getMovies. It's fast too. I think it's being cached?

It all works, so I guess this just becomes a question of: Was this the best approach?

0 投票する
1 に答える
401 参照

typescript - 複数のクエリのセットから特定のクエリを実行する Graphql - ApolloClient

クエリを外部ファイルに保存したいとします。たとえば、次のようにします。

ファイル全体を単一の文字列にロードして、その文字列を ApolloClient に渡し、実行するクエリを選択することは可能ですか?

他のクライアントでこれを行うことは可能ですか? アポロはいらない。

0 投票する
1 に答える
460 参照

apollostack - Mutation で Apollo サブスクリプションが呼び出されないようです

Apollo は初めてなので、見つけた最も単純な例を取り上げ、少し異なる方法で作業することにしました。私のコードはここにあります

私が抱えている問題は、 Mutation を呼び出したときに Subscription が呼び出されないように見えることですcreateTask()。Mutation と Subscription は schema.graphql で次のように定義されています。

そして resolvers.js で次のように:

私が期待しているのは、クライアントで次を実行するたびに、サーバーで console.log を取得することです。

しかし、何も起こりません。私は何が欠けていますか?