Skip to content
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

Client support #111

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Client support #111

wants to merge 19 commits into from

Conversation

VPanteleev-S7
Copy link

Early proof of concept of generating D types from queries/schemas.

This file seems to be an excerpt from an old version of graphql-js:

https://github.com/graphql/graphql-js/blob/9579758ee877962ae9b6f158fe4f6fe3519002f0/src/language/parser.js

However, it is missing declarations from the top of the file and does not seem
to be a valid program.
It is useful to track lockfiles even for library projects, as it allows running
the tests to be more deterministic.
Add ignore rules for:

- static library (created by "dub build")
- test program (created by "dub test")
Prepare for splitting up into sub-packages.
The main goal is to separate the code by external dependencies, so that it is
possible to use parts of this package without requiring a dependency on all of
Vibe.d (for example, if we want to write a GraphQL client).
GraphQL does not really have "reserved keywords" as such, so field names such as
"input", "type" and "query" are valid.

This commit explicitly enumerates alphabetic tokens as valid field names.

This is a bit of a hack and probably should be solved more properly in Darser.
Proof of concept for basic D code generation for type-safe GraphQL
queries (variables and payloads).
Ensure we don't collide with any identifiers called "Nullable" in the GraphQL
schema.
Copy link
Owner

@burner burner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing really to complain about, just a few nitpicks

@@ -0,0 +1,102 @@
name "graphqld"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please keep the dub.json file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't convert it losslessly - we'd lose the comments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe YAML?

baseType = baseType.list.ptr;
wrappers ~= s => s ~ "[]";
}
else if (baseType.name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add { } everwhere

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and they go at the end of the line, phobos style is ugly

static assert(is(typeof(query.ReturnType.snan.get()[0].get().i) == int));
}


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query gets every field in the schema, could you please at a test for 1 field as well please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants