-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
GraphQL plugin config: document what exactly the typeName
is
#18877
Comments
When attaching an external schema - you are grouping all those queries under that fieldname. try renaming Type to CClimate and fieldname to cclimate. and update your query so that the fields of your graphql service are nested under
|
Can you try this? query MyQuery {
graphQlSource(typeName: {eq: "Filter"}) {
fieldName
id
typeName
}
allGraphQlSource {
nodes {
id
typeName
fieldName
}
}
} |
@tbrannam: thanks for the suggestion, it works. Why the particular capitalization for typeName,
gatsby-config.jsmodule.exports = {
plugins: [
{
resolve: 'gatsby-source-graphql',
options: {
typeName: 'BOGUS',
fieldName: 'myRemoteGqlSource',
url: 'https://graphql.cryptoclimate.io',
},
},
],
}; src/pages/index.jsimport React from 'react';
import { graphql } from 'gatsby';
// This query is executed at build time by Gatsby.
export const GatsbyQuery = graphql`
query {
myRemoteGqlSource {
publicFilters {
id
name
}
}
}
`;
export default ({ data }) => {
return (
<div>{JSON.stringify(data)}</div>
)
} If the explanation above for Here's a minimalistic working repo with the @universse: that resulted in all queries nested under With the working repo, GraphiQL looks sane: |
You are correct - both names are fairly arbitrary. The typeName is used, if you peek at the Docs generated in GraphiQL you will see that |
Thanks for the clarifications! I've submitted #18937 to improve the plugin's doc. |
Summary
New Gatsby user, but experienced with GraphQL. I've cloned gastby-with-apollo and I'm trying to use the the gatsby-source-graphql plugin to fetch a basic list of names. I can't figure out what to pass in the
typeName
field of the plugin configuration.Relevant information
In the documentation, the comment above that field is
Overlooking the terse grammar, I don't understand what that comment means, and why that information is necessary, when I'm already specifying the (root) fieldName, and the full GatsbyQuery.
File contents (if changed)
gatsby-config.js
:Relevant information
{ publicFilters { id name } }
(executes fine in the Playground)Unknown field 'id' on type 'Filter!'.
type Filter { id: String!, name: String!, ... }
,type Query { publicFilters(userIds: [String!]): [Filter!]! }
I've tried all sorts of permutations and capitalization of "Filter" and "PUBLICFILTERS" for the
typeName
, but all result in the same error. I can't relate the "RMAPI" fromgastby-with-apollo
, or the SWAPI from other samples to anything in their GraphQL schemas. I'm sure those aren't arbitrary strings, so what am I missing?The text was updated successfully, but these errors were encountered: