GitHub GraphQL API Filter on custom text field in Project V2 - github

We are using GitHub Projects (Beta). I created a custom text field called oma-project. I want to use the API to filter on this field, e.g., oma-project: "P0001". This should return all issues with this value in the custom field.
Looking at the Projects (beta) docs, I can list the first n issues but I don't know how I can pass a filter based on the value of the custom field.
This is as far as I have gotten.
{
node(id: "nodeid") {
... on ProjectV2 {
items(first: 2) {
nodes {
fieldValues(first: 8) {
nodes {
... on ProjectV2ItemFieldTextValue {
text
field {
... on ProjectV2FieldCommon {
name
}
}
}
}
}
content {
... on Issue {
id
title
}
}
}
}
}
}
}
returns:
{
"data": {
"node": {
"items": {
"nodes": [
{
"fieldValues": {
"nodes": [
{},
{},
{},
{
"text": "Retrieve Notes via OData",
"field": {
"name": "Title"
}
},
{},
{
"text": "P9999",
"field": {
"name": "OMA Project"
}
}
]
},
"content": {
"id": "I_kwDOFT-pvM5AZNLm",
"title": "Retrieve Notes via OData"
}
},
{
"fieldValues": {
"nodes": [
{},
{},
{
"text": "Capex Approval Type",
"field": {
"name": "Title"
}
},
{},
{},
{
"text": "P0708",
"field": {
"name": "OMA Project"
}
}
]
},
"content": {
"id": "I_kwDOFT-pvM5K85HZ",
"title": "Capex Approval Type"
}
}
]
}
}
}
}

I'm having the same issue when working on a GitHub action to move a list of items from a status to another status, and it seems currently the API doesn't support ProjectV2 item filtering.
My current workaround is to query all the items from the project and then later filter out the results using jq or JavaScript

Related

Possible Notion API bug - Can't create Database Page with URL data

I have a Notion database that I'm trying to write to via the API.
I can write to text fields, but when I try to write to a URL field, I receive the following error:
{
"object": "error",
"status": 400,
"code": "validation_error",
"message": "body failed validation. Fix one:\nbody.properties.O?HT.id should be defined, instead was `undefined`.\nbody.properties.O?HT.name should be defined, instead was `undefined`.\nbody.properties.O?HT.start should be defined, instead was `undefined`."
}
This is the API description of that field:
"LinkedIn": {
"id": "O%3FHT",
"name": "LinkedIn",
"type": "url",
"url": {}
},
This is the body of the API POST request that's failing:
{
"parent": {
"database_id": "f016c02beeff4a34bf298ceb8a8a079f"
},
"properties": {
"title": [
{
"text": {
"content": "Mark Zuckerberg"
}
}
],
"%3DCzE": [
{
"text": {
"content": "CEO"
}
}
],
"HihI": [
{
"text": {
"content": "Facebook"
}
}
],
"JC%3BS": [
{
"text": {
"content": "Menlo Park, CA"
}
}
],
"O%3FHT": {
"url": "https://www.linkedin.com/in/mark-zuckerberg/"
},
"wS%7BN": {
"url": "https://www.linkedin.com/company/facebook/mycompany/verification/"
}
}
}
I'm basing the body contents on the Postman docs provided by Notion: https://www.postman.com/notionhq/workspace/notion-s-api-workspace/documentation/15568543-d990f9b7-98d3-47d3-9131-4866ab9c6df2

Is it possible to find the project boards an issue is associated with using the Github API?

I'm developing a Github webhook that gets notifications on issue updates.
These issues are associated to one of more Github Project Boards
The body payload shows this information related to the updated issue:
Nothing about issue association with project boards. Is there a way to get this information?
You can use GraphQL API to get that information using projectCards under the Issue object :
{
repository(name: "caipy-dashboard", owner: "bertrandmartel") {
issue(number: 26) {
title
projectCards {
nodes {
createdAt
column {
name
}
project {
name
body
}
}
}
}
}
}
Output :
{
"data": {
"repository": {
"issue": {
"title": "fix dead path in startover",
"projectCards": {
"nodes": [
{
"createdAt": "2017-08-28T05:47:49Z",
"column": {
"name": "Done"
},
"project": {
"name": "Startover",
"body": "Show epg / caipy events + startover modes"
}
}
]
}
}
}
}
}
Try it in the explorer

Gentics Mesh - Multilanguage support - Cross language in a list of node - GraphQL query

Gentics Mesh Version : v1.5.1
Intro:
Let suppose we have schema A with a field of type: list and list type: node and allowed schemas: B. (see (1)).
An instance of B node has been created (b1-EN) in language en and (b1-DE) in de.
An instance of B node has been created (b2-EN) in languages en.
An instance of A node has been created (a1-DE) in language de and b1-DE and b2-EN are added in the node list (Bs) of a1.
As result, when selecting de language in the Gentics Mesh CMS, Node a1-DE (de) has a list of 2 nodes b1-DE, b2-EN.
When the following GraphQL query is applied :
{
node(path: "/a1-DE") {
... on A {
path
uuid
availableLanguages
fields {
Bs {
... on B {
path
fields {
id
}
}
}
}
}
}
}
The result is :
{
"data": {
"node": {
"path": "/a1-DE",
"uuid": "30dfd534cdee40dd8551e6322c6b1518",
"availableLanguages": [
"de"
],
"fields": {
"Bs": [
{
"path": "/b1-DE",
"fields": {
"id": "b1-DE"
}
},
{
"path": null,
"fields": null
}
]
}
}
}
}
Question:
Why the result is not showing the b2-EN node in the list of nodes ? Is the query wrong ? What I would like to get as result is the default language version of the node (b2-EN) because the b2-DE is not contributed yet. so the expected result :
{
"data": {
"node": {
"path": "/a1-DE",
"uuid": "30dfd534cdee40dd8551e6322c6b1518",
"availableLanguages": [
"de"
],
"fields": {
"Bs": [
{
"path": "/b1-DE",
"fields": {
"id": "b1-DE"
}
},
{
"path": "/b2-EN",
"fields": {
"id": "b2-EN"
}
}
]
}
}
}
}
In the documentation (2):
The fallback to the configured default language will be applied if no other matching content found be found. Null will be returned if this also fails.
Can someone enlighten me ?
(1): Schema
{
"name": "A",
"container": false,
"autoPurge": false,
"displayField": "id",
"segmentField": "id",
"urlFields": [
"id"
],
"fields": [
{
"name": "Bs",
"type": "list",
"label": "Bs",
"required": false,
"listType": "node",
"allow": [
"B"
]
},
{
"name": "id",
"type": "string",
"label": "id",
"required": true
}
]
}
(2) https://getmesh.io/docs/graphql/#_multilanguage_support
There are some known issues and inconsistent behaviour when loading nodes via GraphQL. See this issue: https://github.com/gentics/mesh/issues/971
In your case, the queried list of nodes will always be in the configured default language (in mesh.yml). In your case this seems to be de. This is why the English-only node yields no result.
Until this is fixed, you can work around this issue by loading all languages of the node list:
{
node(path: "/a1-DE") {
... on A {
path
uuid
availableLanguages
fields {
Bs {
... on B {
languages {
path
language
fields {
id
}
}
}
}
}
}
}
}
You will the contents of all languages of the node list. This means that you will have to filter for the desired language in your code after receiving the response.

How do I add custom queries in GraphQL using Strapi?

I'm using graphQL to query a MongoDB database in React, using Strapi as my CMS. I'm using Apollo to handle the GraphQL queries. I'm able to get my objects by passing an ID argument, but I want to be able to pass different arguments like a name.
This works:
{
course(id: "5eb4821d20c80654609a2e0c") {
name
description
modules {
title
}
}
}
This doesn't work, giving the error "Unknown argument \"name\" on field \"course\" of type \"Query\"
{
course(name: "course1") {
name
description
modules {
title
}
}
}
From what I've read, I need to define a custom query, but I'm not sure how to do this.
The model for Course looks like this currently:
"kind": "collectionType",
"collectionName": "courses",
"info": {
"name": "Course"
},
"options": {
"increments": true,
"timestamps": true
},
"attributes": {
"name": {
"type": "string",
"unique": true
},
"description": {
"type": "richtext"
},
"banner": {
"collection": "file",
"via": "related",
"allowedTypes": [
"images",
"files",
"videos"
],
"plugin": "upload",
"required": false
},
"published": {
"type": "date"
},
"modules": {
"collection": "module"
},
"title": {
"type": "string"
}
}
}
and the
Any help would be appreciated.
Referring to Strapi GraphQL Query API
You can use where with the query courses to filter your fields. You will get a list of courses instead of one course
This should work:
{
courses(where: { name: "course1" }) {
name
description
modules {
title
}
}
}

Cloudformation SNS template validation error

I am trying to create sns subscription but I am getting template validation error.
'MySNSTopic' is the Logical ID of the cloudformation stack called testsnstopic.
Is this correct. Can anyone explain what value I should give for 'Ref' here
"TopicArn" : {
"Ref": "MySNSTopic"
}
Template validation error:
Template format error: Unresolved resource dependencies [MySNSTopic] in the Resources block of the template
code:
{
"Resources": {
"MySubscription" : {
"Type" : "AWS::SNS::Subscription",
"Properties" : {
"Endpoint" : "test#abc.com",
"Protocol" : "email",
"TopicArn" : {
"Ref": "MySNSTopic"
}
}
}
}
}
To use properties across different stacks, you need to explicitly export the values on the one end and import into the other stack.
In your case you would propably need something like this:
Stack: sns-test
{
"Resources": {
"MySNSTopic": {
"Type": "AWS::SNS::Topic"
}
},
"Outputs": {
"MySNSTopicOutput": {
"Description": "SNS topic arn",
"Value": {
"Ref": "MySNSTopic"
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-MySNSTopicExport"
}
}
}
}
}
Stack: sns-subscription
{
"Resources": {
"MySubscription": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": "jens#apimeister.com",
"Protocol": "email",
"TopicArn": {
"Fn::ImportValue" : "sns-test-MySNSTopicExport"
}
}
}
}
}