apollostack

Apollo GraphQL Mutation (Object Argument)

白昼怎懂夜的黑 提交于 2020-01-04 05:15:28
问题 So, I'm trying to design my Apollo server. I wanted to create a mutation with an object as a parameter. Here is a snippet of my schema which somehow caused the problem: I thought it was syntactically correct, but I ran into this error: {"errors":[{"message":"Expected Input type."}]} 回答1: You have to declare INPUT_OBJECT to be an input type: input INPUT_OBJECT { field1: String, # etc. } 来源: https://stackoverflow.com/questions/39759988/apollo-graphql-mutation-object-argument

Apollo GraphQL Mutation (Object Argument)

两盒软妹~` 提交于 2020-01-04 05:15:10
问题 So, I'm trying to design my Apollo server. I wanted to create a mutation with an object as a parameter. Here is a snippet of my schema which somehow caused the problem: I thought it was syntactically correct, but I ran into this error: {"errors":[{"message":"Expected Input type."}]} 回答1: You have to declare INPUT_OBJECT to be an input type: input INPUT_OBJECT { field1: String, # etc. } 来源: https://stackoverflow.com/questions/39759988/apollo-graphql-mutation-object-argument

How to create a nested resolver in apollo graphql server

梦想的初衷 提交于 2019-12-31 21:44:09
问题 Given the following apollo server graphql schema I wanted to break these down into separate modules so I don't want the author query under the root Query schema.. and want it separated. So i added another layer called authorQueries before adding it to the Root Query type Author { id: Int, firstName: String, lastName: String } type authorQueries { author(firstName: String, lastName: String): Author } type Query { authorQueries: authorQueries } schema { query: Query } I tried the following..

updateQueries after GraphQL mutation not working with the Apollo client

微笑、不失礼 提交于 2019-12-31 02:07:25
问题 After I'm sending a createMessage mutation in my app, I want to update the local ApolloStore using updateQueries. My setup looks as follows: const ChatWithAllMessages = graphql(allMessages, {name: 'allMessagesQuery'})(Chat) export default graphql(createMessage, { props({ownProps, mutate}) { return { createMessageMutation(text, conversationId) { return mutate({ variables: { text, conversationId }, updateQueries: { allConversations: (previousState, {mutationResult}) => { console.log('Chat - did

Issue with automatic UI updates in Apollo: `updateQuery` not working properly with `subscribeToMore`

ⅰ亾dé卋堺 提交于 2019-12-25 07:46:55
问题 I'm using GraphQL subscriptions for my chat application, but I have an issue with the UI updates. Here are the query and the mutation I'm using: const createMessage = gql` mutation createMessage($text: String!, $sentById: ID!) { createMessage(text: $text, sentById: $sentById) { id text } } ` const allMessages = gql` query allMessages { allMessages { id text createdAt sentBy { name location { latitude longitude } } } } ` Then, when exporting, I'm wrapping my Chat component like so: export

Does apollo-client work on node.js?

风格不统一 提交于 2019-12-21 06:53:00
问题 I need a graphql client lib to run on node.js for some testing and some data mashup - not in a production capacity. I'm using apollo everywhere else ( react-apollo , apollo's graphql-server-express ). My needs are pretty simple. Is apollo-client a viable choice? I can find no examples or docs on using it on node - if you're aware of any, please share. Or maybe I should/can use the reference graphql client on node? 回答1: Apollo Client should work just fine on Node. You only have to install

Apollo Server - Confusion about cache/datasource options

佐手、 提交于 2019-12-21 05:23:13
问题 The docs (https://www.apollographql.com/docs/apollo-server/features/data-sources.html#Using-Memcached-Redis-as-a-cache-storage-backend) show code like this: const { RedisCache } = require('apollo-server-cache-redis'); const server = new ApolloServer({ typeDefs, resolvers, cache: new RedisCache({ host: 'redis-server', // Options are passed through to the Redis client }), dataSources: () => ({ moviesAPI: new MoviesAPI(), }), }); I was wondering how that cache key is used, considering it seems