graphql-typed-document-node icon indicating copy to clipboard operation
graphql-typed-document-node copied to clipboard

How to include cursor and other fields in generated DocumentNode

Open dolgorukee opened this issue 3 years ago • 0 comments
trafficstars

I have the following code generated:

export const GetEventsDocument = {
  kind: 'Document',
  definitions: [
    {
      kind: 'OperationDefinition',
      operation: 'query',
      name: { kind: 'Name', value: 'GetEvents' },
      variableDefinitions: [
        {
          kind: 'VariableDefinition',
          variable: {
            kind: 'Variable',
            name: { kind: 'Name', value: 'where' },
          },
          type: {
            kind: 'NamedType',
            name: { kind: 'Name', value: 'EventWhereInput' },
          },
        },
      ],
      selectionSet: {
        kind: 'SelectionSet',
        selections: [
          {
            kind: 'Field',
            name: { kind: 'Name', value: 'events' },
            arguments: [
              {
                kind: 'Argument',
                name: { kind: 'Name', value: 'where' },
                value: {
                  kind: 'Variable',
                  name: { kind: 'Name', value: 'where' },
                },
              },
            ],
            selectionSet: {
              kind: 'SelectionSet',
              selections: [
                { kind: 'Field', name: { kind: 'Name', value: 'count' } },
                {
                  kind: 'Field',
                  name: { kind: 'Name', value: 'edges' },
                  selectionSet: {
                    kind: 'SelectionSet',
                    selections: [
                      {
                        kind: 'Field',
                        name: { kind: 'Name', value: 'node' },
                        selectionSet: {
                          kind: 'SelectionSet',
                          selections: [
                            {
                              kind: 'FragmentSpread',
                              name: { kind: 'Name', value: 'EventFields' },
                            },
                          ],
                        },
                      },
                    ],
                  },
                },
              ],
            },
          },
        ],
      },
    },
    ...EventFieldsFragmentDoc.definitions,
  ],
} as unknown as DocumentNode<GetEventsQuery, GetEventsQueryVariables>

export type GetEventsQuery = {
  __typename?: 'Query'
  events: {
    __typename?: 'EventConnection'
    count: number
    edges?: Array<{
      __typename?: 'EventEdge'
      node?: {
        __typename?: 'Event'
        id: string
        title: string
        category: string
        subcategory: string
        place: string
        address: string
        dateAndTime: any
        description: string
      } | null
    } | null> | null
  }
}

export type EventEdge = {
  __typename?: 'EventEdge'
  cursor: Scalars['String']
  node?: Maybe<Event>
}

How do I customise (other than manually) the generated document so it contains, for example, cursor? Preferably in a way that would allow to make requests with the field included and omitted.

dolgorukee avatar Jul 19 '22 18:07 dolgorukee