Novvum / graphql-birdseye

View any GraphQL schema as a dynamic and interactive graph. 🦅
http://birdseye.novvum.io/
MIT License
704 stars 21 forks source link

[BUG] Example for React project not current for 4.0.0 for createFragmentContainer syntax. #29

Closed changeling closed 5 years ago

changeling commented 5 years ago

Describe the bug

Using BabelPluginRelay, introspectionQuery.tsx yields the error:

Error: babel-plugin-relay/macro: BabelPluginRelay: Expected exactly one definition per graphql tag. Learn more: https://www.npmjs.com/package/babel-plugin-relay
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)

introspectionQuery.tsx

Maybe update to implement createFragmentContainer() syntax for fragments.

To Reproduce Use declared introspection query with babel-plugin-relay/macro. Encounter above error.

Expected behavior Not encountering above error.

Package react

Additional context See: BabelPluginRelay Error in 4.0 and Breaking change

Caveat I'm just getting my feet wet with React, and it is entirely possible I'm completely misunderstanding what's going on here. ::cha-grin:: If that's the case, please gently slap me and move on with your day. :)

changeling commented 5 years ago

I've worked around this issue by doing the following (this'll be long, apologies in advance):

const IntrospectionQuery = graphql`
  query IntrospectionQuery {
      __schema {
      queryType {
        name
      }
      mutationType {
        name
      }
      subscriptionType {
        name
      }
      types {
        kind
        name
        description
        fields(includeDeprecated: true) {
          name
          description
          args {
            name
            description
            type {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                    ofType {
                      kind
                      name
                      ofType {
                        kind
                        name
                        ofType {
                          kind
                          name
                          ofType {
                            kind
                            name
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
            defaultValue
          }
          type {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                    ofType {
                      kind
                      name
                      ofType {
                        kind
                        name
                        ofType {
                          kind
                          name
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          isDeprecated
          deprecationReason
        }
        inputFields {
          name
          description
          type {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                    ofType {
                      kind
                      name
                      ofType {
                        kind
                        name
                        ofType {
                          kind
                          name
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          defaultValue
        }
        interfaces {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                    ofType {
                      kind
                      name
                      ofType {
                        kind
                        name
                      }
                    }
                  }
                }
              }
            }
          }
        }
        enumValues(includeDeprecated: true) {
          name
          description
          isDeprecated
          deprecationReason
        }
        possibleTypes {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                    ofType {
                      kind
                      name
                      ofType {
                        kind
                        name
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      directives {
        name
        description
        locations
        args {
          name
          description
          type {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                    ofType {
                      kind
                      name
                      ofType {
                        kind
                        name
                        ofType {
                          kind
                          name
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          defaultValue
        }
      }
    }
  }
`

But yeah, Yay fragments!

rohit-ravikoti commented 5 years ago

Hey @changeling, Is this issue resolved for you now or is additional work necessary?

Thanks!

changeling commented 5 years ago

Hey, @rohit-ravikoti,

Has something changed in the code? I was able to work around it, as mentioned above, by explicitly stating the entire introspectionQuery, sans fragments, but would love to see it working as presented in https://github.com/Novvum/graphql-birdseye/blob/master/example/src/utils/introspectionQuery.tsx.

The last commit I see shows as 21 days ago, so I haven't tried. Is there something changed that I'm missing?

rohit-ravikoti commented 5 years ago

Hey @changeling, No, there haven't been any changes since that last commit. That's really strange.

changeling commented 5 years ago

I used the entire query as a JSON import, which works fine, bypassing the use of introspectionQuery.tsx. Is there something you'd like me to try to figure this out, or just let it go?

rohit-ravikoti commented 5 years ago

Please reopen if this becomes an issue.