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

Supporting GraphQL schemas #82

Open
praneetloke opened this issue Jul 29, 2023 · 2 comments
Open

Supporting GraphQL schemas #82

praneetloke opened this issue Jul 29, 2023 · 2 comments
Assignees

Comments

@praneetloke
Copy link
Member

Some cloud providers only support GraphQL for their public API. It would be good to understand how we can use GraphQL introspection to gather information CRUD operations for resources.

@praneetloke praneetloke self-assigned this Jul 29, 2023
@praneetloke
Copy link
Member Author

The following introspection query allows us to fetch mutations (substitute mutationType for queryType for queries) and their return types. Since GraphQL does not have HTTP verbs, we'll have to use the operation name as a hint for what type of operation a certain query will perform in the backend. For example, createXYZ or deleteXYZ is for creating and deleting a type called XYZ.

{
  __schema {
    mutationType {
      fields {
        name
        description
        type {
          ofType {
            name
            kind
            ofType{
              name
              kind
              ofType{
                name
                kind
              }
            }
          }
        }
      }
    }
  }
}

@praneetloke
Copy link
Member Author

And this query returns all types along with their fields:

{
  __schema {
    types {
      name
      fields {
        description
        deprecationReason
        name
        type {
          name
          ofType{
            kind
            name
            ofType{
              kind
              name
            }
          }
        }
      }
    }
  }
}

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

No branches or pull requests

1 participant