I like GraphQL and another libraries around GraphQL. I like GraphQL tools. But I found that I need a relation map. I thought that such tool had to exist. But I have not found. Does it exist?
If you are asking for a visual representation of relations, you could use GraphQL introspection to achieve this. Take a look on GraphQL Voyager:
Demo:
https://apis.guru/graphql-voyager/
Copy the introspection query, paste and run it on your GraphQL API endpoint.Copy the results into GraphQL Voyager. You should get a nice visual representation of your data relations available through your GraphQL API.
Github:
https://github.com/APIs-guru/graphql-voyager
Related
I have a client that queries 2 endpoints. Now, how do I auto-generate types from 2 graphql schemas, when using 2 endpoints?
Scripts I used up until now (with standard 1 endpoint) uses Apollo codegen (source):
"schema": "npx apollo service:download --endpoint=http://localhost:8080/graphql graphql-schema.json",
"types": "npm run schema && apollo client:codegen --localSchemaFile=graphql-schema.json --variant=development --target=typescript --addTypename --queries=./src/**/*.graphql --useReadOnlyTypes --globalTypesFile=src/globalTypes.ts . && npm run prettier"
Possible solution is also generating 2 introspection schemas and then merging them together, I just didn't find how.
I'm also open to move to Graphql Code Generator.
Is there any example, guidance, or link please?
Thank you
GraphQL Code Generator supports configuring multiple schemas by merging their definitions automatically for you.
You will find some documentation on this matter here: https://www.the-guild.dev/graphql/codegen/docs/config-reference/schema-field#multiple-schemas-and-client-side-schema
Please note that schema can take an array of schema file paths or URLs.
Let us know if you need any guidance migrating from Apollo codegen.
Charly, from The Guild.
I am using Nest JS for server and new to Graphql, I want to create a graphql server but schema defines in Graphql module in app.module. I am using schema first appraoch.
app.module
in importing Graphql Module, typepaths property defines to create typings from schemas present in any path.
but I don't have any particular schema because I want my user to enter any thing he want and fetch data using Graphql where typings should be with respect to particular user.
Things I tried:
I tried to rewrite the schema using filesystem methods from service but to update typings from schema nest server needs to restart to generate typings again.
please anyone give me a guide or any approach how can I achieve dynamic typings. I want a server which shows a graphql playground but user should be allow to query with respect to their data.
like for user 1 this highlighted box can be a schema but for different user this schema should be with respect to himself:user 1 should see this schema and should query only using this schema
Related Images are attached in link.
Any guide would be appreciated, Thanks!
One can document a REST API with OpenAPI. Is there a similarly clean and standardized way of documenting gRPC APIs? E.g. specify what values an endpoint is expecting, what the return values mean, etc. The service definitions in a .proto file do not suffice as documentation.
I just found this: https://gendocu.com/
which let you try your APIs and document the fields. Also generates code for different languages. The project looks promising.
We are planning to migrate towards Apollo GraphQL, because of the Apollo federation feature which allows unifying multiple microservices behind a single GraphQL API. However we are using TypeGraphQL at the moment, and I believe them to be incompatible. The reason is that in Apollo federation I see you use special #key property
/* example from docs */
const typeDefs = gql`
type Query {
me: User
}
type User #key(fields: "id") {
id: ID!
username: String
}
`;
However, the schema for TypeGraphql is automatically generated from classes. Is there a way to still use both technologies, or they are mutually exclusive?
Typegraphql had added the support for it, check the examples here https://github.com/MichalLytek/type-graphql/tree/master/examples/apollo-federation
While it has support by using #Directive decorator, it's not quite easy to work with it on a large scale project. I'm currently implementing it on a complex project, and I'm not satisfied with the amount of boilerplate code needed to reference some type from another schema. There was some conversation about adding better support here:
https://github.com/MichalLytek/type-graphql/issues/351#issuecomment-549156066
I'm planning to add support if I will have time soon.
but it's still not implemented. I've created a repo where you can see minimal example (similar to one in type-graphql repo):
https://github.com/hrvojepavlinovic/apollo-federation-type-graphql
I am a newbie in graphql and I am trying to create a sever which will take few parameters and a few files (like images) as parameters in mutation.
I am using graphql-yoga and it is very clear how to implement it using graphql-yoga.
My question is how to test it?
How can I test the file upload from graphql playground?
I am going to use react-relay so are there any examples to do it in react-relay.
Thanks.
Neither GraphiQL nor GraphQL Playground support file uploads. You can use a standalone client like Altair.