Questions tagged [apollo]

Apollo is a GraphQL client and cache for JavaScript, iOS (Swift) and Android.

Apollo is a flexible, fully-featured client for every platform.

Apollo is made up of a family of technologies you can incrementally add to your stack: Apollo Client to connect data to your UI, Apollo Engine for infrastructure and tooling, and Apollo Server to translate your REST API and backends into a GraphQL schema.

It has implementations for JavaScript, iOS and Android. The JavaScript client has integrations for React, Angular, Vue.js, Ember.js and more.

Apollo is fully compatible with any server that implements the GraphQL specification.

4536 questions
9
votes
1 answer

Resolving Types in Graphql

There are couple of places in GraphQL where resolving a Type is required and not just a field in a Type. The Backend API - /users - list of users - minimal info - name, id /users/:id - detailed user info /foo - returns a field owner which is a…
Boopathi Rajaa
  • 4,659
  • 2
  • 31
  • 53
8
votes
1 answer

Apollo React Why Can't Query inside UseEffect hook

I am just learning about Apollo-React but I couldn't make graphql request This is how I do without Apollo const Search = () => { const [searchedText, setSearchedText] = React.useState('') const [suggestions, setSuggestions] =…
mr_nocoding
  • 472
  • 7
  • 16
8
votes
0 answers

React re-render causing Apollo useQuery to be called twice

I have a simple React component that uses Apollo's useQuery to fetch data. The problem is, because the component is being rendered twice, it is calling useQuery twice, which is then calling the Apollo resolver twice, which is then calling the…
Ben
  • 5,085
  • 9
  • 39
  • 58
8
votes
0 answers

Vercel 504 Bad Gateway Error Page though code works in dev mode

So I have built a Next app based on this NextJS example which means I have GraphQL routes and an Apollo server I use to fetch from the API in the app. The example shows how to fetch in getStaticProps() which works fine for me but I need to implement…
8
votes
1 answer

Add nested fields in cache typePolicies - Apollo v3

I am wondering if it is possible to have nested values using typePolicies of the InMemoryCache For now you can define flat fields policies new InMemoryCache({ typePolicies: { Query: { fields: { hello: { read() { …
Simon Bruneaud
  • 2,263
  • 2
  • 12
  • 24
8
votes
2 answers

Return incomplete shapes from resolver with GraphQL Code Generator

I use the following convention to let resolvers return partial data, and allow other resolvers complete the missing fields: type UserExtra { name: String! } type User { id: ID! email: String! extra: UserExtra! } type Query { user(id:…
Fez Vrasta
  • 14,110
  • 21
  • 98
  • 160
8
votes
0 answers

Apollo Graphql mocking fragment data

I have managed to use Apollo's data mocking for queries. This is what I have so far: import { addMocksToSchema } from '@graphql-tools/mock' import { buildClientSchema, graphql } from 'graphql' import schemaJson from './schema.json' const schema =…
Hoffmann
  • 14,369
  • 16
  • 76
  • 91
8
votes
1 answer

apollo graphql mutation - Unexpected end of JSON input

I'm making a simple test with @apollo/react-hooks, and I'm getting this error: ApolloError.ts:46 Uncaught (in promise) Error: Network error: Unexpected end of JSON input at new ApolloError (ApolloError.ts:46) at Object.error…
8
votes
1 answer

Apollo error handling - why react app crashes?

is somebody able to explain, why my react app + apollo behaves like this when I try to use mutation which returns error? GraphQL mutation returns this (response code is 200):…
8
votes
4 answers

Mock specific graphql request in cypress when running e2e tests

When running e2e tests with Cypress, my goal is to mock a specific graphql query. Currently, I can mock all requests like this: cy.server(); cy.route('POST', '/graphql', { data: { foo: 'bar' }, }); The problem is that this mocks all…
DauleDK
  • 3,313
  • 11
  • 55
  • 98
8
votes
1 answer

How to properly pass variables to apollo useQuery?

So I need a pair of fresh eyes to help me out! I just started using the new hooks for apollo and they are pretty cool! However, I am running into an issue when I try to pass variables, it returns undefined. I have this query in a graphql server…
aromanarguello
  • 626
  • 4
  • 11
  • 23
8
votes
2 answers

How to get the name of a query from a `gql` object?

I use gql from graphql-tag. Let's say I have a gql object defined like this: const QUERY_ACCOUNT_INFO = gql` query AccountInfo { viewer { lastname firstname email phone id } } ` There must be a way to get…
Vladyslav Zavalykhatko
  • 15,202
  • 8
  • 65
  • 100
8
votes
3 answers

GraphQL queries showing error in the .graphQl file

I am doing a demo project on graphql queries. Followed all the required steps and downloaded schema.json from my dummy graphql server on graphcool. However when I am writing the .graphql file which contains the graphql queries, android studio is…
Jigsaw
  • 81
  • 1
  • 4
8
votes
2 answers

missing attribute on result, Vue, Apollo and GraphQL

Im totally new to developing with Apollo & GraphQL in Vue applications, and have been stuck on a small problem for some time now. I keep getting the error: Missing clients attribute on result I can see that the request returns data in the Network…
user431619
8
votes
1 answer

Is it possible to have partially federated gateway?

I'd like to federate services, but let the federation gateway also hold own schema and logic that would proxy REST API endpoints for simplicity. Now it looks like I need to have federation gateway service, federated graphql service(s) and the…
Ville
  • 464
  • 4
  • 14