Questions tagged [graphql-tag]

GraphQL Tag is a JavaScript template literal tag that parses GraphQL queries.

GraphQL Tag or gql is a open source template literal tag you can use to concisely write a GraphQL query that is parsed into the standard GraphQL AST.

Documentation

59 questions
35
votes
1 answer

GraphQLError: Syntax Error: Expected Name, found

I got the above error on a graphql query, I am using apollo-react by the way and using the Query component for rendering the data this is my code const GET_VEHICLE_CHECKS = gql` query getVehicleChecks($uuid: String!) { tripDetails(uuid: $uuid){ …
malik bagwala
  • 1,338
  • 2
  • 11
  • 26
32
votes
8 answers

GraphQL gql Syntax Error: Expected Name, found }

I'm attempting to set up Apollo GraphQL support in a new React project, but when I try to compile a query using gql I keep receiving the error: Syntax Error: Expected Name, found } This is generated by the following code: import gql from…
Nathan
  • 1,187
  • 2
  • 10
  • 16
29
votes
3 answers

GraphQL dynamic query building

I have a GraphQL server which is able to serve timeseries data for a specified source (for example, sensor data). An example query to fetch the data for a sensor might be: query fetchData { timeseriesData(sourceId: "source1") { data { …
Matt Wilson
  • 7,359
  • 7
  • 28
  • 51
5
votes
1 answer

Graphql-config does not recognize Apollo Graphql @client directive

I'm using Apollo Client with React, graphql-tag loaded with Webpack, and graphql-config to maintain the schema on the client. There is a file ./myclient/src/features/stats/graphql/getStart.graphql query GetStart { start @client } where start…
Adam S
  • 468
  • 8
  • 22
5
votes
1 answer

Nextjs-Graphql webpack loader: How to integrate Nextjs with Graphql loader

I am trying to integrate Nextjs with graphql-tag/loader, This is my next.config.js file: const withSass = require('@zeit/next-sass') const graphqlLoader = require('graphql-tag/loader') module.exports = withSass({ webpack: (config, { buildId, dev,…
acmoune
  • 1,655
  • 2
  • 13
  • 29
5
votes
3 answers

How to test GraphQL queries with fragments using jest

Problem: I would like to test a GraphQL query that lives in a .graphql file like this: #import '../../fragments/Widget.graphql' query WidgetFragment($id: ID) { readWidgetFragment(id: $id) { ...Widget } } To create a GraphQL schema…
4
votes
3 answers

Apollo-react compose query is not a function

I am trying to compose a react component with the following queries, but the query getMe is always an object and then I get TypeError: this.props.getMe is not a function. If I change it to a mutation then it all works. If I use the query in the…
Brenwell
  • 697
  • 8
  • 23
3
votes
1 answer

graphql-tag/loader: Module build failed with GraphQLError: Syntax Error

Weird issue I am facing. Using Vue-CLI3 npm run serve. Have the following config: // vue.config.js module.exports = { chainWebpack: config => { // GraphQL Loader config.module .rule('graphql') .test(/\.graphql$/) …
Daniel da Rocha
  • 827
  • 7
  • 25
3
votes
1 answer

Is it possible to put variables inside a GraphQL-tag?

Right now I have this tag below. It's static and will always get a comment with the id of 3. Is there a possible way to put a variable inside this graphQL-tag. So I can re-use the graphQL-tag, and just change the variable ID? export const…
3
votes
0 answers

Why I get Argument of undefined passed to parser was not a valid GraphQL DocumentNode?

I do import graphQL query as: import {getStudents} from'./../graphql/Queries.graphql' Queries.graphql file: query getStudents($schoolID: Int!){ allStudents(schoolId: $schoolID){ pickUpLat pickUpLng } } but when I try to pass the query…
simo
  • 20,548
  • 31
  • 101
  • 188
2
votes
2 answers

graphql-codegen dynamic fields with interpolation

I'm using graphql-codegen to generate typescript types from graphql schema. I'm trying to create a fragment with dynamic fields. schema.ts This is the type generated by graphql-codegen. /** User Type */ export type UserType = { __typename?:…
in3pi2
  • 749
  • 1
  • 8
  • 20
2
votes
2 answers

Why do you need graphql-tag with Apollo

Following some tutorials and examples, I integrated a GraphQL API into a simple Vue application. I'm using Apollo to interact with the API and graphql-tag's provided template literal to write the queries, like so: gql` query getUser($userId: ID)…
Criss
  • 712
  • 4
  • 15
2
votes
1 answer

Webpack loader for graphql-tag not loading in Angular 8

I have been following this guide https://www.apollographql.com/docs/angular/recipes/webpack/ but I am getting this error when I execute ng serve: ERROR in ./src/app/shared/queries.graphql 1:6 Module parse failed: Unexpected token (1:6) You may…
Ashkan Hovold
  • 798
  • 2
  • 10
  • 26
2
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
  • 8,954
  • 4
  • 49
  • 84
2
votes
0 answers

Error in Vue graphql: Missing query attribute on result

I want to have multiple queries in one network request. I have put all my queries in vue Apollo but I get this error when data revived(I will get the data in network tab but I cant access it!) error: vue-apollo.esm.js?522d:842 Missing query…
Amir Meimari
  • 378
  • 4
  • 16
1
2 3 4