Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query to get project planning board #119

Open
Kartikey-star opened this issue Feb 14, 2024 · 0 comments
Open

Query to get project planning board #119

Kartikey-star opened this issue Feb 14, 2024 · 0 comments

Comments

@Kartikey-star
Copy link

I am trying to follow the https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects?tool=cli [Finding the node ID of a field](https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects?tool=cli#finding-the-node-id-of-a-field).

The query being used here is :

gh api graphql -f query='
query{
node(id: "PROJECT_ID") {
... on ProjectV2 {
fields(first: 20) {
nodes {
... on ProjectV2Field {
id
name
}
... on ProjectV2IterationField {
id
name
configuration {
iterations {
startDate
id
}
}
}
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}'

I am trying to convert this query to a golang struct and use the following:

type (
ProjectV2IterationFieldFragment struct {
id string
name string
configuration struct {
iterations struct {
startDate string
id string
}
}
}
ProjectV2SingleSelectFieldFragment struct {
id string
name string
options struct {
id string
name string
}
}
)

var projquery struct {
	Node struct {
		fields struct {
			Nodes struct {
				Id    string
				Title string
			} `graphql:"... on ProjectV2Field "`
			ProjectV2IterationFieldFragment    `graphql:"... on ProjectV2IterationField "`
			ProjectV2SingleSelectFieldFragment `graphql:"... on ProjectV2SingleSelectField "`
		} `graphql:"... on ProjectV2"`
	} `graphql:"node(id:\"my_project_id\")"`
}

The error which i get here is Fragment on ProjectV2Field can't be spread inside ProjectV2. What wrong am i doing here?

Other than that do you have a recommended resource which can help us getting familiar with converting graphql queries to structs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant