graphql.github.io | GraphQL Documentation at graphql.org | GraphQL library
kandi X-RAY | graphql.github.io Summary
kandi X-RAY | graphql.github.io Summary
This repository contains the source code for the GraphQL website.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of graphql.github.io
graphql.github.io Key Features
graphql.github.io Examples and Code Snippets
Community Discussions
Trending Discussions on graphql.github.io
QUESTION
I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and express. In both cases, we pass the schema and resolver functions while creating the server instance.
But the implementation of resolver function differs. While using graphql-yoga, the resolver function is provided with 4 arguments which contains information about the parent object, arguments received, context, info. whereas in the other case (using graphql), the resolver function only gets the arguments object.
Why is that so ? If I want the info, context objects, how do I get it ?
Using graphql-yoga example: https://graphql.org/learn/execution/
Using graphql example: https://graphql.github.io/graphql-js/mutations-and-input-types/
// Code example using graphql
...ANSWER
Answered 2020-Feb-19 at 12:52REAL TALK: the GraphQL.js docs are not that great. In my opinion, they never should have used examples with buildSchema
in the first place because it understandably leads to this kind of confusion.
GraphQL.js (i.e. the graphql
package) is the JavaScript implementation of GraphQL. Building a schema in GraphQL.js is done programmatically, by constructing an instance of the GraphQLSchema
class:
QUESTION
Assume a simple schema like
...ANSWER
Answered 2020-Jan-29 at 18:42(Copying response from issue)
Actually, I think that it is valid. The spec says :
- If selectionType is an interface, union, or object
The subselection set of that selection must NOT BE empty
It simply states that it must contain a subselection (could be an inline fragment as in your example). It doesn't specify that its subselections must be leaf field selections.
I agree that in essence it should actually contain leaf selections for every possible subtype of the field's return type (e.g Human
and Droid
in your scenario), otherwise it could return an empty response. For instance, if there are no humans and 3 droids in your database then it would return:
QUESTION
what's the difference between schema and documents in Graphql?
schema is like this:
...ANSWER
Answered 2019-Dec-19 at 22:55A document is really any string containing valid GraphQL syntax. According to the spec, a document contains one or more definitions, where a definition could be:
an operation definition
QUESTION
I'm documenting all my types, fields and parameters in my schema (SDL), including Query
and Mutation
at the top - but I can't work out how to add a single piece of documentation for the top-level of the whole schema.
I'm not sure if it's the spec or the tooling - Apollo for example allows me to write schema { }
, but not to put anything inside it, or documentation before it.
And there are no examples of it in the docs, particularly at https://graphql.github.io/graphql-spec/June2018/#sec-Descriptions, which shows a "well-described" schema without a top-top-level doc string.
Is this something the spec doesn't cover, or just the tooling?
...ANSWER
Answered 2019-Jun-24 at 22:03Unlike types, the SchemaDefinition
spec does not contain a Description
. The __Schema
introspection type also does not have a description
field. So there is no way to set or get a description for the entire schema.
It is, however, an upcoming feature.
QUESTION
We are migrating our Apollo Graphql Server v1 projects to v2.
We noticed that there is a change in the error response format.
In v2, the errors list in the response is wrapped within an error object.
But, in v1, it is not so. We want to have a a consistent standard and not introduce the wrapping behaviour in v2.
I understand that GraphQL services may provide add additional fields via extensions as per below link. Link: https://graphql.github.io/graphql-spec/June2018/#sec-Errors
I have tested Apollo GraphQL V2 and this is how it is implemented there.
In v1 it is as expected.
In v1,we see error response as below,
...ANSWER
Answered 2019-May-11 at 10:54This behavior has not changed in version 2. Apollo Server produces spec-compliant responses and does not not wrap any resulting errors in an error
object. Instead, this is just a known bug with GraphQL Playground. With version 2.0, Apollo Server transition from GraphiQL to GraphQL Playground. GraphiQL did not have this same issue, which is why this looks like a bug with Apollo Server. Check the network tab and look at the actual response from your server -- it's actually in the expected format.
QUESTION
I have seen that inserting an Input Type is recommended in the context of mutations but does not say anything about queries.
For instance, in learn tutorial just say:
This is particularly valuable in the case of mutations, where you might want to pass in a whole object to be created
I have this query:
...ANSWER
Answered 2019-Apr-13 at 19:54No, there is nothing incorrect about your approach. The GraphQL spec allows any field to have an argument and allows any argument to accept an Input Object Type, regardless of the operation. In fact, the differences between a query and a mutation are largely symbolic.
It's worth pointing out that any field can accept an argument -- not just ones at the root level. So if it suited your needs, you could easily set up a schema that would allow queries like:
QUESTION
While experimenting with the Union types in GraphQL here: https://graphql.github.io/learn/schema/#union-types I ran into the following:
I initially thought that the fields you specify in the query are the fields that going to be searched for the text: "Millenium", however that's not the case because I'm still getting the Millenium Falcon's data even after removing the name field from the query for the Startship
type.
I did another test: R2-D2's primaryFunction
is Astromech
, if you search for Astromech
you'll get nothing, even if primaryFunction
is specified for Droid
type.
ANSWER
Answered 2019-Feb-07 at 12:10Note that name is still specified on Starship because otherwise it wouldn't show up in the results given that Starship is not a Character!
That simply means that because we are using a Union type, given two types that are part of the Union that both have a name
field, you still have to request the name
field for each type in their inline fragment. Omitting the name
for the Starship
fragment, but including it on Character
, means if the returned type is a Character
the name field will be present but it will not be present on the Starship
type.
The docs are mentioning this to highlight the difference between Unions and Interfaces. If SearchResult was an Interface that included the name
field and Character
and Starship
implemented that Interface, you could do something like this instead:
QUESTION
I've noticed that https://graphql.github.io/ uses fixed viewport's width
...ANSWER
Answered 2018-Nov-25 at 22:51Devices with less than 640px width will zoom out the content (if you set initial-scale=1 then devices won't zoom it out and you have horizontal scroll).
It looks good on mobile but it looks small and you have to zoom in to read some texts.
The advantage is that you don't need to design your site for resolutions below 640px, but the tradeoff is that users have to zoom in.
QUESTION
I'm using create-react-app with apollo client and I followed the coding which is on apollo docs. My server is configured apollo server with express and I tested it followed the GraphQL Clients way. It works but when I tried to use apollo client way It doesn't work. Here's my code.
In index.js file
...ANSWER
Answered 2018-Sep-04 at 03:14if you want to test a query in a lifecycle method I would use the higher order component "withApollo"
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install graphql.github.io
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page