Questions tagged [graphql]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 views

Is it possible to invalidate the GraphQL cache for a single query?

I have a pretty large website that benefits greatly from the GraphQL cache, but it seems like it's a single site-wide config in the Craft config/app.php file. I would need to invalidate the cache from ...
0
votes
0answers
13 views

Graphql: How to get all entries and all related entries

I am really new to graphql and the jamstack-thing but i was wondering how is it possible to query all "Events" with all related "Speaker"? Events and Speaker are two sections. In ...
0
votes
0answers
27 views

Create a structure entry with GraphQL in one trip

I was wondering if it is possible to create a structure with multiple children and nested entry via GraphQL with one mutation query? For now, I can only create the first level entry of the structure ...
0
votes
0answers
58 views

How do you create a GraphQL mutation to upload a file for an entry's asset field?

In my mutation I need to upload a file to an Asset Field. Can this all be done in one mutation or do you need to upload the file in one mutation and assign the id to the asset field in a secondary ...
0
votes
0answers
11 views

Custom GraphQL Resolver that utilizes the same craft function used in twig

I'm pretty new to Craft CMS or PHP for that matter. I have custom code that unfortunately can't be done with just GraphQL so I need to utilize the same functions used in a twig template, in a custom ...
1
vote
1answer
20 views

Return a single element instead of an array in a GraphQL query

Consider the following GraphQL query: { entries { ...on posts_default_Entry { image { id } } } } This will return the following: { "data": { "...
1
vote
0answers
16 views

GraphQL next does not accept 'relatedToCategories'

I'm trying to get the next project in the "projects" section but with the same category. So because I can't do it in one query (the value of my category is in the result), I do another query ...
0
votes
0answers
17 views

Same table field in two different sections/sites causes GraphQL error

Given this mutation (which adds rows to a table) mutation { save_thesection_thetype_Entry ( siteId: 1, title: "test titel", ...
0
votes
0answers
13 views

How to set tags via graphQL?

I'm trying to create entries programmatically and setting tags on them. However, I can't figure out if this is possible or not, and can't find documentation explaining this. I'm basically trying to do ...
2
votes
1answer
26 views

How to get enabled entry with GraphQL, enabledForSite has been deprecated?

Based on the docs https://craftcms.com/docs/3.x/graphql.html#the-entries-query enabledForSite can be used for entries. This works for me to get the enabled entries, however I get a deprecation error ...
0
votes
0answers
26 views

Bearer Authorization not working Safari

I'm using craft 3.7.16 as headless and retrieving the data through GraphQL. I've identified that Safari is not working when we have a bearer authorization. It seems that it changes the bearer to basic ...
0
votes
0answers
32 views

Get related entries / users filtered by relation field name in GraphQL

I wonder if it's possbile to deal with the following situation with Craft CMS in graphQL: We have users related to projects in two different ways: users.bookmarkedProjects = [projectIds] project....
1
vote
1answer
15 views

Graphql schema causing error on project-config/apply

Craft v3.5.7 First off, graphql is not being used on this site so I'm not sure why the schemas are being generated and causing errors. The graphql.yml file contents: publicToken: enabled: false ...
1
vote
1answer
55 views

Why can't I see my programmatically-created Entries in GraphQL/GraphiQL?

I am using a module controller to create Entries, like this: $personEvent = new Entry(); $personEvent->sectionId = 6; $personEvent->typeId = 1; $personEvent->authorId = $user->id; $...
1
vote
1answer
23 views

Graphql mutations with json

Can someone confirm for me that the current status of craftql (Craft 3.7) does not allow mutations that can save JSON content to entries?
1
vote
1answer
367 views

How do I write a GraphQL query to search through sub-entries/entries as fields and return the whole entry?

So I have a fairly complex section structure that (on an Entry Type) has a matrix field that contains entries as fields(sub-entry) within a blocktype. I'd like to write a GraphQL query such that when ...
0
votes
0answers
102 views

Get categories with the number of entries

I would like to retrieve the categories of a group, the name and their fields, but with each one the number of entries that have this category assigned. It's like this question but I'm not using twig ...
0
votes
0answers
38 views

Problem with Int conversion when making a graphql request

Have a site that uses jquery, so trying to make calls to the graphql api using $.ajax(). It works fine for simple queries, but when trying to pass Int values for parameters, I keep hitting a variable ...
2
votes
1answer
103 views

Craft CMS GraphQL count query

I've got the GraphQL code posted below, but I'm not sure how do I count the total of returned products . Do I need another query just for the products without offset ? I need it for a pagination ...
2
votes
1answer
273 views

Is it possible to write a custom GraphQL resolver for Craft?

I am currently editing a headless VueJS + Craft + GraphQL website and the client asks me to add a Recipe section. I found https://plugins.craftcms.com/recipe which is great, but when I add the field ...
1
vote
1answer
87 views

GraphQL: get prev / next entry from current entry (channel)

Is there a way to get the prev and next entry from the current entry, when this entry is inside a channel and not a structure? query ($id: [QueryArgument], $rel: Int) { entry: entry(id: $id) { ...
1
vote
1answer
42 views

GraphQL mutation or query, how to target specific site?

Is there a restriction on graphQL that only allows it to work on the primary site? My system has for unknown reason switched primary (and I can't change it back due to a bug), and ever since then my ...
0
votes
0answers
62 views

Craft CMS Graphql orderBy random - pagination?

How does pagination work with orderBy: 'RAND()' queries? I've setup a page that loads assets on scroll. If I'm ordering by random, how does offset:2 work? Is each query a new random selection from all ...
0
votes
0answers
44 views

Searching for specific MatrixBlocks with either GraphQL or PHP

I'm building a search for my Craft site right now. Finding entries is fine. I usually have the structure that one entry is one site in the frontend. I sadly also have entries that are way longer. So ...
1
vote
1answer
472 views

WARNING: heuristic fragment matching going on! when querying matrix fields or any query with multiple fragment types with Graph QL using Nuxt Apollo

I am relatively new to using Craft Headlessly and am trying to query matrix fields with Nuxt JS and it's Apollo module. I have discovered, that although the graphQL queries work in the GraphiQl ...
0
votes
0answers
161 views

GraphQL returning array on entries field with limit set to 1, instead of 1 object/entry

If I do a GraphQL query on an asset (entries field type, limit set to 1), I get an array in return. Even if I limited the asset to just 1 in the field. So my GraphQL returns: "image": [ { &...
2
votes
1answer
427 views

Fetching Unique Categories related to Entries via GraphQL

Suppose I have some entries in a section called 'product' that are related to a category call 'brand' - I know I can get the brands that are related to each product that match a search term using ...
2
votes
1answer
498 views

Updating Entry field with GraphQL mutation

I'm trying out the GraphQL mutations and would like to issue an update of an Entry, triggered from a webhook. However, documentation on mutations seems sparse, and I find GraphQL highly confusing. ...
4
votes
1answer
261 views

Using a GraphQL mutation to append a block to a Neo field

I know how to update simple fields on an entry using a mutation: mutation updateRecipe($recipeId: ID, $slug: String) { save_recipes_recipe_Entry(id: $recipeId, slug: $slug) { id title ...
1
vote
1answer
82 views

Create folder in asset volume via GraphQL

Is it possible to create a subfolder within an asset volume via GraphQL? If yes, can you point me in the right direction? I just found mutations for file uploading, but nothing for folder creation. ...
1
vote
1answer
138 views

How can I have created data (id) returned for a GraphQL mutation?

I have a mutation which is successfully creating an entry, but the data returned for the mutation does not include the fields I specify, such as id. mutation saveWindowCleaningRequest($title: String!, ...
1
vote
1answer
189 views

Filter for language when using graphQL

I try to use graphQL to get language specific entries from my Craft CMS. I (naively?) tried this: query { entries (section: "newsIntranet", language: "fr") { title ...
1
vote
1answer
110 views

Fetch pending entries with GraphQL

I'm setting up Craft to be used headlessly with a mobile app, and content will be created several days before it is published. I want app admins to be able to see upcoming/pending entries. Is there a ...
1
vote
1answer
2k views

GraphQL query entries by DateTime field between two dates

I am trying to query entries in GraphQL by custom DateTime field value. It works with the base String value like ">=2020-10-01", However querying between two dates like "['and', '>...
1
vote
1answer
81 views

How can I change the Date Created for Assets?

I'm using graphql to pull in some assets/pdfs and ordering them by dateCreated, however the files go back a few years (i.e. files from 2019, files from 2018 etc.) but they weren't uploaded in the ...
1
vote
0answers
214 views

Filter entries in GraphQL

I'm using Craft with Gatsby. I'd like to query a featuredpost, and filter that in my entries. I'm getting the featuredPost slug in gatsby-node, and passing that to createPage, to send a variable to my ...
1
vote
1answer
241 views

Uploading Asset Doesn't Clear GraphQl Cache with VueJS/Axios

Context: I have a VueJS method that uses a form and Axios to upload an asset to an entry's asset field. The method successfully uploads the asset to the entry, and I can prove that fact via the ...
2
votes
1answer
671 views

Graphql total results / pageinfo when searching with pagination

I'm trying to build something to search my data that is stored in Craft with graphql. To make pagination work I want to know how many results there are in total. I'm doing a query like this: query($...
1
vote
1answer
147 views

Query for Lightswitch in GraphQL

I have two entry types that I want to show in a sorted list (by postDate, with paginating). { entries( type: ["entryType1", "entryType2"], orderBy: "postDate desc", limit: 5, offset:...
2
votes
1answer
181 views

GraphQL: Prevent users seeing entries authored by other users

How can we filter what entries are returned by a GraphQL query so that users cannot see entries authored by other people? For example, Editors can access everything but Writers can only access their ...
2
votes
1answer
562 views

CraftCMS + GraphQL - orderBy Random?

I'm currently building my first JAM stack app using Nuxt as my front-end framework and Craft as my headless CMS. I'm leveraging Apollo as my GraphQL interface client. I have it pulling data back just ...
3
votes
1answer
367 views

In GraphQL how to query entries where related entry has a specific value

Lets have this query: query test { entries(section: "vacancies") { title ... on vacancies_vacancies_Entry { description organisation { title ... on ...
2
votes
1answer
571 views

How to return custom fields in GraphQL

This is definitely a noob question, but I can't seem to find an answer to this. (Completely new to GraphQL). I'm trying to simply return entries: query test { entries(section: "vacancies", limit: ...
1
vote
1answer
189 views

getting active userid by GraphQL?

I build a SPA with Craft CMS and Vue. I use Vue Router and have three Props. Here is my current router-view: <router-view csrfName="{{craft.app.config.general.csrfTokenName}}" csrfToken="{{...
1
vote
1answer
450 views

GraphQL two image transforms for same field

To get image transform in GraphQL we use this image { url @transform ([width: 300, immediately: true]) } But how do I get two different image transforms (for responsive image) for this asset ...
3
votes
0answers
835 views

Multiple Entry Types on GraphQL Fragment

So I am building out a Gatsby Site, which is using Craft in Headless mode as it's content source. In one Section, I have three entry types. Currently they have identical fields, but may diverge in the ...
1
vote
1answer
888 views

GraphQL - Get related entries based on tags field

I'm trying to retrieve entries related to the current entry, based on a tag field called topics. Simple stuff. Now, I use Craft's native GraphQL implementation so I'm bound to the possibilities this ...
1
vote
1answer
77 views

How to loop through Craft CMS query in Angular

Given the following query sample, how can I loop through the entries past the first array in Angular? Here is the query sample: query sample ($section: [String], $type: [String], $slug: [String]) { ...
2
votes
1answer
290 views

How can I retrieve Users of a specific User Group with GraphQL?

I want all the users but filtered by User Group: query getAllUsers { users { id, username } } I cannot see any query parameter on the Schema
1
vote
1answer
178 views

GraphQL private schema returning public schema scope

I am setting up GraphQL on my Craft project, v3.3.16.3 I have a public schema exposing a public entry type, and a private schema exposing a private entry type. When I switch between them in the ...