-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
Using GraphQL Voyager without the endpoint #238
Comments
@isha-talegaonkar you can build an introspection from file and use it. If you check the demo, you can get some clues on how to make it. |
Hi,
I am still unsure on how I can go about this. Can you please point me
towards some files I can look at to understand better?
Thanks,
Isha
…On Wed, Jul 13, 2022 at 1:08 PM Stefano ***@***.***> wrote:
@isha-talegaonkar <https://github.com/isha-talegaonkar> you can build an
introspection from file and use it. If you check the demo, you can get some
clues on how to make it.
—
Reply to this email directly, view it on GitHub
<#238 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH3FGXFODVXGXTGM4DESOETVT4O4NANCNFSM53PQNQ5A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Is this possible with the standalone version? It's probably easiest to use |
@isha-talegaonkar you might need to provide more info regarding your project. You can always build and dump a complete SDL or get an introspection. |
Here is an example on how you can do this without an endpoint: import {
Source,
parse,
execute,
buildSchema,
} from 'graphql'
import type {
DocumentNode,
} from 'graphql'
import { Voyager, voyagerIntrospectionQuery } from 'graphql-voyager';
var schema = buildSchema(`
type Account {
Id: String
Name: String
}
type Objects {
Account: Account
}
type UIAPI {
query: Objects
}
type Query {
Account(Id: String): Account
uiapi: UIAPI
}
`)
async function retrieveDemoIntrospection(introspectionQuery){
let documentAST: DocumentNode | undefined;
try {
//const params = await getGraphQLParams(request)
documentAST = parse(new Source(introspectionQuery, 'GraphQL request'));
} catch (syntaxError: unknown) {
// Return 400: Bad Request if any syntax errors exist.
//documentAST = new DocumentNode()
throw new Error("failed")
}
return execute({
schema,
document: documentAST,
rootValue: {},
contextValue: {},
variableValues: {},
operationName: "IntrospectionQuery",
fieldResolver: undefined,
typeResolver: undefined,
});
} You can extend field and type resolver which can be very helpful when you schema is dynamic. |
My project does not have a graphql endpoint as such, but a bunch of input graphql schema files that I am getting using an API. I need to visualize the file that I am getting as input. Is there any way to do so?
The text was updated successfully, but these errors were encountered: