Aryan Iyappan
Aryan Iyappan
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
hey, are you using django by any chance?
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
Don't use strawberry.ID in the schema after defining your own ID scalar
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
Um, not really, you just need to define a new scalar (as mentioned above) and use it consistenly within the schema
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
I think the issue is, after creating a scalar like this;
ID = strawberry.scalar(
strawberry.ID,
serialize=lambda value: str(value),
parse_value=lambda value: GlobalID.from_id(value=value),
)
ID = strawberry.scalar(
strawberry.ID,
serialize=lambda value: str(value),
parse_value=lambda value: GlobalID.from_id(value=value),
)
You are using strawberry.ID in your schema. You should be using your own ID scalar instead
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
hey @rodaan can you show me the logs of the TypeError?
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/27/2024 in #🤔questions
Should I use dataloaders in relay.Node.resolve_nodes?
Oh that's actually a brilliant idea!
7 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/27/2024 in #🤔questions
Should I use dataloaders in relay.Node.resolve_nodes?
off the top of my head, I think it would be nice if we could somehow pass the required argument to the dataloader, something like:
dataloader.load_many(keys, required=True)
dataloader.load_many(keys, required=True)
so that the dataloader fetch function can handle this logic..
7 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
But then again, this would be a major change and would require core Dev approval, any inputs guys?
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
So that raises a question- why not make the relay node types return the ID type directly itself? As in other implementations such as graphql-relay-js??
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
But then GlobalID would be nothing else but a class with a couple of methods- including from_id
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/27/2024 in #🤔questions
Should I use dataloaders in relay.Node.resolve_nodes?
Oh, right! Thank you! So my doubt is.. is it a common pattern to implement two separate dataloaders: one which raises an error and another one which does not?
7 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
Sure, at the top of my head, I'm thinking, we separate the resolve_node and resolve_node_sync methods into standalone functions
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
Could we redo the API such that the globalID.resolve_node and globalID.resolve_node_sync methods are separate, standalone functions? @bellini 🤔
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
Would prs on this be accepted? I would like to contribute!
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
Mm, I think it would be nice if we could still keep the global id abstraction, just not make it a scalar
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
cc @contributors
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
the relay specification calls this scalar as ID only, so why is strawberry outputting this as GlobalID??
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
Here's the error I get from relay:
> client@0.0.0 relay
> relay-compiler

[INFO] [default] compiling...
[ERROR] Error: ✖︎ Invalid use of @deleteEdge on field 'deletedTodoId'. Expected field type 'ID', got 'GlobalID'.

client/src/components/home-page/Todo.tsx:20:21
19 │ deleteTodo(todoId: $todoId) {
20 │ deletedTodoId @deleteEdge(connections: $connections)
│ ^^^^^^^^^^^
21 │ }

[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
Failed to build:
- Validation errors: 1 error(s) encountered above.
> client@0.0.0 relay
> relay-compiler

[INFO] [default] compiling...
[ERROR] Error: ✖︎ Invalid use of @deleteEdge on field 'deletedTodoId'. Expected field type 'ID', got 'GlobalID'.

client/src/components/home-page/Todo.tsx:20:21
19 │ deleteTodo(todoId: $todoId) {
20 │ deletedTodoId @deleteEdge(connections: $connections)
│ ^^^^^^^^^^^
21 │ }

[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
Failed to build:
- Validation errors: 1 error(s) encountered above.
29 replies
SGStrawberry GraphQL
Created by Aryan Iyappan on 6/28/2024 in #🤔questions
relay.GlobalID naming issue?
type Todo implements Node {
"""The Globally Unique ID of this object"""
id: GlobalID!
content: String!
completed: Boolean!
createdAt: DateTime!
updatedAt: DateTime
}

type TodoConnection {
"""Pagination data for this connection"""
pageInfo: PageInfo!

"""Contains the nodes in this connection"""
edges: [TodoEdge!]!
}

"""An edge in a connection."""
type TodoEdge {
"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: Todo!
}
type Todo implements Node {
"""The Globally Unique ID of this object"""
id: GlobalID!
content: String!
completed: Boolean!
createdAt: DateTime!
updatedAt: DateTime
}

type TodoConnection {
"""Pagination data for this connection"""
pageInfo: PageInfo!

"""Contains the nodes in this connection"""
edges: [TodoEdge!]!
}

"""An edge in a connection."""
type TodoEdge {
"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: Todo!
}
this is the schema currently being generated while using the strawberry relay integration. However, this outputs all the IDs under a scalar named GlobalID The issue for me is, while using relay on the frontend, the relay compiler expects these fields to be of the scalar named ID exactly, while updating the data after mutations, using directives
29 replies