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

71 questions
2
votes
0 answers

Slow query performance: MongoDB with $lookup and $and/$or

I'm trying to find a way to create an engine that translates GraphQL query filters to MongoDB aggregations while keeping the performance. Our application has the requisite of limiting the results from collection A by applying filters to collection…
2
votes
1 answer

Defining JSON/Object type in graphql-tag

I'm kinda new to Apollo gql, just wondering if anyone know if its possible to define Object class in graphql-tag? export const CREATE_STYLE = gql` mutation styleCreate( $formID: String! $fontFamily: Object //how do you define…
Amy Lee
  • 277
  • 3
  • 15
1
vote
1 answer

Apollo Client, gql from graphql-tag or @apollo/client

I have some queries with import { gql } from '@apollo/client'; // from Apollo Client 3 and other with: import gql from 'graphql-tag'; What's the difference between using one or another? I had to change the one imported from apollo/client to…
pmiranda
  • 7,602
  • 14
  • 72
  • 155
1
vote
1 answer

How to use constant data instead of query field name?

In my React(Apollo client) App, for creating queries I am using gql`` tag from graphql-tag package, I am wandering if following is somehow possible to achieve: const bookField = 'books' const GET_BOOKS = gql` query getBooks { ${bookField} { …
Vano
  • 690
  • 3
  • 8
  • 25
1
vote
2 answers

GraphQL Tag dynamic table name in query (apollo)

In my app every customer has a own table for its data. Depending on which customer was selected I want to dynamically build the tablename for the Graphql query. For example: // Query for customer 1 gql` query overviewQuery { customer_1 { …
Thomas K.
  • 121
  • 1
  • 10
1
vote
1 answer

What the /src means when installing npm package?

I try to build (again) a React project that worked very well before the client calls me and tells me that it has crashed. When building (npm run build) I just get this : Creating an optimized production build... Failed to…
4bdl
  • 9
  • 5
1
vote
2 answers

How to get useLazyQuery hooks data after calling a function

I'm trying to to call useLazyQuery after submitting form/onClick, but for some reason I'm always getting undefined. Here is how I have defined my hook; const component = () => { const [getMyValues, {loading, error, data: myValues}] =…
1
vote
1 answer

ApolloClient: Can't pass GraphQL query as a JS variable? "Invariant Violation: Expecting a parsed GraphQL document."

I'm using vue-apollo + vue-property-decorator. I'm able to run queries just fine like this: get apollo () { return { rc_tags: { query: gql`{ }` } } } But if I try to use a property of the component…
Ascendant
  • 944
  • 1
  • 10
  • 28
1
vote
2 answers

GraphQL mutation - confusion designing gql tag for Apollo Client

I need help figuring out the GraphQL tag for use with Apollo Client. The Docs don't go far beyond the most basic use case for mutations. My goal is to have the only required input be an email. If the other variables are present, I would like those…
realhat
  • 177
  • 1
  • 1
  • 9
1
vote
0 answers

How do I set an @client variable in the results of a nested query based on the index of the element

Given below is the query that fetches a list of products and stores it in the apollo-client local cache. It retrieves a list of products and the list of images for every product const GET_PRODUCTS_QUERY = gql` query Products($cursor: String,…
Jophin Joseph
  • 2,864
  • 4
  • 27
  • 40
1
vote
1 answer

Unexpected : Can a graphql file only import other files and do nothing else?

I am using apollo-server-express to run my GraphQL server with a prisma database. My main schema is listed below, which just uses graphql-tag/loader to import other .graphql files. When I try to run my server locally, I get the following…
Jimmy
  • 3,090
  • 12
  • 42
  • 99
1
vote
1 answer

Make a mutation call multiple times depending on length of variable

Is there a way for me to call a mutation multiple times from the front-end? I have an array of users I need to add to an app and the mutation currently only allows to add one user at a time (we could change the mutation but they want to see if I can…
caraclarke
  • 370
  • 1
  • 5
  • 24
1
vote
1 answer

How update Apollo Cache with a lot of active queries

I have a lot of active queries stored in my Apollo Cache, for example: items(isPublished: true, orderBy: "name", filterByName: "") items(isPublished: true, orderBy: "name", filterByName: "home") items(isPublished: false, orderBy: "name",…
Jose Ramos
  • 673
  • 3
  • 10
1
vote
0 answers

How to return distinct data using gql from apollo-boost

I am working with a React component implemented with TypeScript where I am querying some data using gql from apollo-boost library. First time user so have little knowledge. const GET_COUNTRIES = gql` query GET_COUNTRIES { users { …
PineCone
  • 2,193
  • 12
  • 37
  • 78
1
vote
1 answer

GraphQL response type / fragment struggle

I have some struggles with writing an API in graphql. Every response in my api should look somewhat the same. So ideally this would be the graphql type: type Response { success data { ... always different } errors { path message …
Bas Kaal
  • 75
  • 2
  • 8