-
Notifications
You must be signed in to change notification settings - Fork 54
Import typescript file in schema: Syntax Error: Cannot parse the unexpected character "." #436
Comments
👋 Can you share the contents of |
Hello @jasonkuhrt Sure, here is my
And, here is my
|
schema: ./src/makeExecutableSchema.ts Should be schema: ./src/schema.ts |
Thanks for the reply @jasonkuhrt but that too gives the same error.
|
Thanks @jasonkuhrt for your patience! Yes, I am using |
@devautor same to you :) I'll try to take a closer look at this tonight or failing that in the coming days. |
Oh, sure! I hope you could find time for this tonight, or sooner than later (I have my timeline set to "Write resolvers" from |
Hey @maticzav on your end are you experiencing any issues having graphqlgen get schema from your TS module? |
Hi @jasonkuhrt Thank you so much for your fix; but I am not able to get it running still, am I doing something wrong here:
|
I only just published the new version. Give 0.6.0-rc6 a try. |
Sorry @jasonkuhrt my bad! Trying with rc6 is still producing the same error to me:
|
Can you show me the output of:
And then, what happens if you try this: # update your graphqlgen.yml to have this field:
schema: test-schema.graphql
|
Hello @jasonkuhrt I had shared
Output is:
For completeness, I did
|
hey @devautor 👋 Could you briefly explain how the list as a schema thing works? I haven’t seen it before but it looks very interesting. @jasonkuhrt, |
Hey @maticzav a fan here :) Kindly let me know if I have done something lazy here :) P.S. BTW I was about to message you on twitter regarding |
@devautor since I don't have access to your project, and since you now have a hyper-minimal example schema working, can you start from the tester I gave you and incrementally make it be like yours, testing |
@jasonkuhrt I recall that the minimal example I got working was from a graphql file, and couldn't get one working from a ts file. But, I understand and appreciate your point. I will try to do that (maybe it could take time, since I am pressed down by a huge schema :) ) |
@devautor what happens with (ts version):
|
@jasonkuhrt I am sorry that I didn't report that... Here's what I get:
My
And, my
|
It’s as if graphqlgen is trying to parse the path to the file, rather than the file contents. I haven’t been able to repro. Can you make a small repo or code sandbox where I can interact with the repro myself? |
Hi @jasonkuhrt I have a mini-reproduction on my local system, my free codesandbox limit is up. Please allow me some time. EDIT: Hello again @jasonkuhrt and @maticzav I have reproduced and shared the issue here in this repo, kindly review https://github.com/devautor/graphqlgen-issue-reproduction :) |
@devautor thanks! Will take a look tonight |
My investigation is below. Some takeaways
new shell
Then I did ❯ gd
diff --git a/src/test-schema.ts b/src/test-schema.ts
index 3827ded..2530f86 100644
--- a/src/test-schema.ts
+++ b/src/test-schema.ts
@@ -1,7 +1,7 @@
import { gql } from "apollo-server";
const typeDefs = gql`
- extend type Query {
+ type Query {
a: String
}
`;
❯ cat ./src/generated/graphqlgen.ts
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import { GraphQLResolveInfo } from "graphql";
import { Context } from "../context";
export namespace QueryResolvers {
export const defaultResolvers = {};
export type AResolver =
| ((
parent: undefined,
args: {},
ctx: Context,
info: GraphQLResolveInfo
) => string | null | Promise<string | null>)
| {
fragment: string;
resolve: (
parent: undefined,
args: {},
ctx: Context,
info: GraphQLResolveInfo
) => string | null | Promise<string | null>;
};
export interface Type {
a:
| ((
parent: undefined,
args: {},
ctx: Context,
info: GraphQLResolveInfo
) => string | null | Promise<string | null>)
| {
fragment: string;
resolve: (
parent: undefined,
args: {},
ctx: Context,
info: GraphQLResolveInfo
) => string | null | Promise<string | null>;
};
}
}
export interface Resolvers {
Query: QueryResolvers.Type;
} |
Morning @jasonkuhrt A little confusion here, you wrote that "couldn't reproduce your error", and also that "removing extend made it work"; so did you get the same error as mine with Also, I am using Regarding Thank you for all your attention to such tiny details Jason, and do let me know what am I doing stupid here, or what should Ibdo next! |
No, I pasted exactly what I did and saw in my code blocks
Ah I see, please chime in/upvote #181 as yes I would like to make it unnecessary.
Makes sense! I'll look more into the Thanks for sharing your repro via a repo, it was very helpful! |
@jasonkuhrt Upvoted that, adding that feature would be really helpful (since different tools do bring different design choices, so swapping would not be easy with a codebase as heavy as mine, I guess). While you look into Thank you to you Jason for making such tools, you guys are the magic :) |
:) As a workaround for now, if you centralize your schema so as to not need |
Oh @jasonkuhrt that'd not be so easy or desirable to me, but I am not complaining :) I would really wish to have supports for |
@devautor discovered that the reason
Also, I have not been able to repro your reported issue of:
Is this still what you are stuck on? |
Hello @jasonkuhrt Sorry, I had missed this comment of yours! I am definitely getting the same error as reported with |
No, to my knowledge you simply cannot use |
Oh @jasonkuhrt I see, but EDIT: Downloaded
Also, for comparison,
Should I open independent issue for this, or is this a known and fixable issue? |
There have been similar issues in the past, however presently none open I think. Feel free to open one.
Good to know, something to review when we tackle the issue inside |
All right @jasonkuhrt I will open one issue, because I want those pretty default resolvers (grapqhl-code-generator works and is awesome too, but has higher cognitive load initially :) ). |
Hi @jasonkuhrt Bad news, most of this happened because I'm lazy :) While trying to reproduce #449 I realized that I was using global install of
Update: On running
|
How do I import a typescript file as the schema in
graphqlgen
configuration.I am using graphql-code-generator to generate types from my schema using:
schema: http://localhost:4000/graphql
Then, as I am trying to use
graphqlgen
to generate resolvers from these generated types and the schema.I am getting this error:
My
graphqlgen.yml
is:The text was updated successfully, but these errors were encountered: