graphql-js

Update state with Apollo Client

大城市里の小女人 提交于 2019-12-10 22:36:34
问题 I am trying to use ApolloClient with Vuex but I stumbled upon a problem I can't resolve. I call ApolloClient.query() function inside a vuex action but it seems like the function always returns a resolved promise from the first action call. So, after the function got fired once, no request goes to the server and I get the same result as when I load the page (although the actual data in database gets changes). If I take a look at Apollo Dev Tools, there's also no changes to the Apollo state

GraphQL schema from a single object JSON file in Gatsby

时间秒杀一切 提交于 2019-12-10 19:57:53
问题 So I'd like to query a single JSON file which is not an array from Gatsby's GraphQL but I don't really know how to do it. As far as I understand gatsby-transformer-json docs - it only supports loading arrays and have them accessible via allFileNameJson schema. My gatsby-config plugins (only the necessary ones for this question): { resolve: 'gatsby-source-filesystem', options: { name: 'data', path: `${__dirname}/src/data` } }, 'gatsby-transformer-json' And then let's say in src/data i have a

Graphql with nested mutations?

白昼怎懂夜的黑 提交于 2019-12-10 10:55:08
问题 I am trying to figure out how to mutate a nested object with graphql mutations, if possible. For instance I have the following schema: type Event { id: String name: String description: String place: Place } type Place { id: String name: String location: Location } type Location { city: String country: String zip: String } type Query { events: [Event] } type Mutation { updateEvent(id: String, name: String, description: String): Event } schema { query: Query mutation: Mutation } How can I add

Remove unnecessary fields before mutation in GraphQL

泄露秘密 提交于 2019-12-08 17:32:06
问题 I've got a type called Article in my schema: type Article { id: ID! updated: DateTime headline: String subline: String } For updates to it, there's a corresponding input type that is used by a updateArticle(id: ID!, article: ArticleInput!) mutation: input ArticleInput { headline: String subline: String } The mutation itself looks like this: mutation updateArticle($id: ID!, $article: ArticleInput!) { updateArticle(id: $id, article: $article) { id updated headline subline } } The article is

Unexpected <EOF> while using graphql

空扰寡人 提交于 2019-12-08 17:19:11
问题 Getting EOF error every time at same line, changed code many times and even degraded to previous versions of graphql but no positive results. My code is: const graphql = require('graphql') const _ = require('lodash') const { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLSchema } = graphql const users = [ {id: '1', firstName: 'Ansh', age: 20}, {id: '2', firstName: 'Ram', age: 21}, {id: '3', firstName: 'Sham', age: 20} ] const UserType = new GraphQLObjectType({ name: 'User', fields: { id

Passing down arguments using Facebook's DataLoader

余生长醉 提交于 2019-12-08 15:16:38
问题 I'm using DataLoader for batching the requests/queries together. In my loader function I need to know the requested fields to avoid having a SELECT * FROM query but rather a SELECT field1, field2, ... FROM query ... What would be the best approach using DataLoader to pass down the resolveInfo needed for it? (I use resolveInfo.fieldNodes to get the requested fields) At the moment, I'm doing something like this: await someDataLoader.load({ ids, args, context, info }); and then in the actual

Error: Can only create List of a GraphQLType but got: function GraphQLObjectType(config) , in GraphQL?

爷,独闯天下 提交于 2019-12-08 13:34:34
问题 I am working on a demo project on GraphQL. But stuck here. I want to send the whole object as result. The object which I want to send is: exports.fakeDatabase = { 1: { id: 1, name: 'Abhay', description:'This is Abhay\'s Database' }, 2: { id: 2, name:'Bankimchandra', description: 'This is Bankimchandra\'s Database' }, 3: { id: 3, name:'chandu', description: 'This is chandu\'s Database' } }; But when I am sending a request to access it I got Error: Error: Can only create List of a GraphQLType

How to send custom error in AppSync with $util.error

非 Y 不嫁゛ 提交于 2019-12-08 07:37:33
问题 I have a question about AppSync error handling. I would like to send errorInfo object along with the error response and I tried with $util.error . Per the document: https://docs.aws.amazon.com/appsync/latest/devguide/resolver-util-reference.html $util.error(String, String, Object, Object) Throws a custom error. This can be used in request or response mapping templates if the template detects an error with the request or with the invocation result. Additionally, an errorType field, a data

GraphiQL Returning null Values When Fetching All Records [duplicate]

限于喜欢 提交于 2019-12-08 03:28:03
问题 This question already has an answer here : Why does a GraphQL query return null? (1 answer) Closed 6 months ago . I am trying to build a simple GraphQL schema. I have an json-server endpoint running on localhost which returns some simple json data. I can return a user when supplying an id. The query to do this in the schema looks like this: staff: { type: StaffType, args: { id: { type: GraphQLInt }}, resolve(parentValue, { id }) { return axios.get(`http://localhost:3000/staff/${id}`) .then

Fetch additional data for a single item in a list query

牧云@^-^@ 提交于 2019-12-07 22:44:38
问题 Im trying to do something like this with React and Relay - smooth animation from list to single item. I currently have list component (list query) and single item component (node query) but there's a problem: these are two different, isolated views and queries, I can't think of an easy way to smootly animate between these two views. Easiest way would probably be to transform / scale that same list item: React part is simple, I'll calculate screen size on click and transform the list item to