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

Refactor/entgql autobinding #35

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions archivist.graphql

This file was deleted.

62 changes: 28 additions & 34 deletions cmd/archivistctl/cmd/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ func init() {
}

func printSubjects(results retrieveSubjectResults) {
for _, edge := range results.Dsses.Edges {
for _, subject := range edge.Node.Statement.Subjects {
digestStrings := make([]string, 0, len(subject.SubjectDigest))
for _, digest := range subject.SubjectDigest {
digestStrings = append(digestStrings, fmt.Sprintf("%s:%s", digest.Algorithm, digest.Value))
}

fmt.Printf("Name: %s\nDigests: %s\n", subject.Name, strings.Join(digestStrings, ", "))
for _, edge := range results.Subjects.Edges {
digestStrings := make([]string, 0, len(edge.Node.SubjectDigests))
for _, digest := range edge.Node.SubjectDigests {
digestStrings = append(digestStrings, fmt.Sprintf("%s:%s", digest.Algorithm, digest.Value))
}

fmt.Printf("Name: %s\nDigests: %s\n", edge.Node.Name, strings.Join(digestStrings, ", "))
}
}

Expand All @@ -103,41 +101,37 @@ type retrieveSubjectVars struct {
}

type retrieveSubjectResults struct {
Dsses struct {
Subjects struct {
Edges []struct {
Node struct {
Statement struct {
Subjects []struct {
Name string `json:"name"`
SubjectDigest []struct {
Algorithm string `json:"algorithm"`
Value string `json:"value"`
} `json:"subject_digest"`
} `json:"subjects"`
} `json:"statement"`
Name string `json:"name"`
SubjectDigests []struct {
Algorithm string `json:"algorithm"`
Value string `json:"value"`
} `json:"subjectDigests"`
} `json:"node"`
} `json:"edges"`
} `json:"dsses"`
} `json:"subjects"`
}

const retrieveSubjectsQuery = `query($gitoid: String!) {
dsses(
subjects(
where: {
gitoidSha256: $gitoid
hasStatementWith:{
hasDsseWith:{
gitoidSha256: $gitoid
}
}
}
) {
edges {
node {
statement {
subjects {
name
subject_digest {
algorithm
value
}
}
}
}
}
}
node{
name
subjectDigests{
algorithm
value
}
}
}
}
}`
8 changes: 4 additions & 4 deletions cmd/archivistctl/cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ type searchResults struct {
Dsses struct {
Edges []struct {
Node struct {
GitoidSha256 string `json:"gitoid_sha256"`
GitoidSha256 string `json:"gitoidSha256"`
Statement struct {
AttestationCollection struct {
Name string `json:"name"`
Attestations []struct {
Type string `json:"type"`
} `json:"attestations"`
} `json:"attestation_collection"`
} `json:"attestationCollections"`
} `json:"statement"`
} `json:"node"`
} `json:"edges"`
Expand All @@ -124,9 +124,9 @@ const searchQuery = `query($algo: String!, $digest: String!) {
) {
edges {
node {
gitoid_sha256
gitoidSha256
statement {
attestation_collection {
attestationCollections {
name
attestations {
type
Expand Down
Loading