question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Similar to your comment about unions not be implemented yet, what about interfaces?

See original GitHub issue

This works when querying github, though snowflaq cannot validate it w/“unknown field author”

{
	"name": "author",
	"description": "The actor who authored the comment.",
	"args": [],
	"type": {
		"kind": "INTERFACE",
		"name": "Actor",
		"ofType": null
	},
	"isDeprecated": false,
	"deprecationReason": null
},

query GetPullRequests($org: String!) {
  organization(login: $org) {
    name
    url
    repositories(first: 100) {
      nodes {
        name
        pullRequests(first: 100, states: OPEN) {
          nodes {
            number
            title
            url
            body
            author {
              login
            }
            reviews(last: 10, states: APPROVED) {
              nodes {
                author {
                  login
                }
              }
            }
          }
        }
      }
    }
  }
}

** this could just be me not knowing much about graphql…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Zaid-Ajajcommented, Jul 26, 2020

Hi @mattsonlyattack,

It has been a long and exciting weekend. I think I have got this implemented like it should 😁 Snowflaqe now understands both GraphQL interfaces and unions, generates the corresponding F# union types and verifies the used fields just like it does with objects. The only requirement is that the subtypes both on interfaces and unions must now add a __typename field and will otherwise throw a validation error. This field is used for deserialization.

It would be great if you could put this version to the real test and run it against the Github schema that you working with. You have to modify your query slightly into this:

query GetPullRequests($org: String!) {
  organization(login: $org) {
    name
    url
    repositories(first: 1) {
      nodes {
        name
        pullRequests(first: 1, states: MERGED) {
          nodes {
            number
            title
            url
            body
            author {
              login
              url
            }
            mergedBy {
              login
              resourcePath
            }
            reviews(last: 10, states: APPROVED) {
              nodes {
                author {
                  avatarUrl
                  login
                  ... on Bot {
                    __typename
                    login
                    id
                  }
                  ... on User {
                     __typename
                    bio
                    id
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Please let me know how it goes and whether everything works for you 😄

1reaction
Zaid-Ajajcommented, Jul 21, 2020

@mattsonlyattack Thanks a lot for the sample queries! I think I know now where to look to find a solution. I am afraid however that it will be quite the challenge to implement this feature. I can’t promise a timeline but I will definitely look into it soon

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript - When to use Discriminated Unions vs Classes ...
The key difference between discriminated unions and interfaces is that interfaces are open for extension, but unions are not.
Read more >
c# - In what way are union types better for correctness than ...
Note that interfaces and union types have dual properties. An interface makes it easy to introduce new alternatives (the implementing classes) ...
Read more >
remove union types and allow interfaces to have no fields ...
As you quoted from the spec, Unions are defined locally while Interfaces are defined by implementation of each Object type. This models the...
Read more >
Types vs. interfaces in TypeScript
It can be difficult to choose between types and interfaces in TypeScript, but in this post, you'll learn which to use in specific...
Read more >
Union types - #120 by kyay10 - Language Design
Right now, as I am writing an app in Kotlin, my project is littered with enum classes like SignInError, NetworkError, ExecuteRequestError, and they...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found